最近要做四参数拟合
公式为:y = (a-d)/(1+(c/x).^b)+d
给出5组数据,需要求出相应的abcd的值.
由于对算法一块不是很熟.只能靠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);
end
end
%disp (results);
% Inputs: 1. a 1 dimensional array of drug concentrations
1. 一个浓度的一维数组
% 2. the corresponding m x n array of responses
2. 相应的m*n矩阵结果
2到底是什么
因为公式中x为浓度,
因此conc应该是浓度
2我就搞不明白了.
我只有5组数据
respon= [22929;62436;283398;817634;1483682]
这样错误,提示
??? Error using ==> rdivide
Matrix dimensions must agree.
Error in ==> init_coeffs at 17
if (y(1)-y(sizey))./(x(2)-x(sizex))>0
Error in ==> ec50 at 28
initial_params=init_coeffs(conc,response);
respon= [22929,62436,283398,817634,1483682]
也不对