关于四参数的算法以及MATLAB调用的传参问题.
y=(a-d)/(1+(x/c)^b)+d
数据由数据库读取
例如有如下数据:
X Y
0.10015929
0.50062436
5.000283398
30.000817634
150.0001483682
如何用matlab求出对应的abcd
实际abcd参考值为:
a2218196
d5741
c59.4407
b0.7614
找了很久也就找到一份关于matlab算四参数的资料,不知道接口到底怎么传参
ec50.m 主入口
function results=ec50(conc,responses)% EC50 Function to fit a dose-response data to a 4 parameter dose-response% curve.% % Requirements: nlinfit function in the Statistics Toolbox% and accompanying m.files: init_coeffs.m and sigmoid.m% Inputs: 1. a 1 dimensional array of drug concentrations 1. 一个浓度的一维数组% 2. the corresponding m x n array of responses 2. 相应的m*n矩阵结果% Algorithm: generate a set of initial coefficients including the Hill% coefficient% fit the data to the 4 parameter dose-response curve using% nonlinear least squares% Output: a matrix of the 4 parameters% results[m,1]=min% results[m,2]=max% results[m,3]=ec50% results[m,4]=Hill coefficient%% Copyright 2004 Carlos Evangelista % send comments to CCEvangelista@aol.com% Version 1.0 01/07/2004%conc = conc';%responses = responses';[m,n]=size(responses);results=zeros(n,4);for i=1:n response=responses(:,i); initial_params=init_coeffs(conc,response); [coeffs,r,J]=nlinfit(conc,response,'sigmoid',initial_params);% disp (coeffs); for j=1:4 results(i,j)=coeffs(j); endend%disp (results);
function init_params = init_coeffs(x,y)% INIT_COEFFS Function to generate the initial parameters for the 4% parameter dose response curve.% Requires an array of doses and an array of responses% This function is used by sigmoid.m and ec50.m%% Copyright 2004 Carlos Evangelista % send comments to CCEvangelista@aol.com% Version 1.0 01/07/2004parms=ones(1,4);parms(1)=min(y);parms(2)=max(y);parms(3)=(min(x)+max(x))/2;sizey=size(y);sizex=size(x);if (y(1)-y(sizey))./(x(2)-x(sizex))>0 parms(4)=(y(1)-y(sizey))./(x(2)-x(sizex));else parms(4)=1;endinit_params=parms;
function yhat=sigmoid(params4,x)% SIGMOID Function to fit data to a four parameter dose response curve% requires the nlinfit function of the statistics toolbox and a set of % initial parameters such as the one generated by init_coeffs.m.% This function is used by ec50.m%% Copyright 2004 Carlos Evangelista % send comments to CCEvangelista@aol.com% Version 1.0 01/07/2004min=params4(1);max=params4(2);ec=params4(3);hillc=params4(4);x1=x(:,1);yhat=min+(max-min)./(1+(x1/ec).^hillc);
result页可以看到你要求的模型、各未知数计算结果。