首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

关于四参数的算法以及MATLAB调用的传参有关问题

2012-11-04 
关于四参数的算法以及MATLAB调用的传参问题.y(a-d)/(1+(x/c)^b)+d数据由数据库读取例如有如下数据:XY0.10

关于四参数的算法以及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 主入口

C/C++ code
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);


init_coeffs.m
Assembly code
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;


sigmoid.m
C/C++ code
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);


谁知道怎么做啊??传参试了几个形式不是提示错误就是算出来完全不对?

[解决办法]
实际abcd参考值为:
a2218196
d5741
c59.4407
b0.7614

这个结果是错的!
y=(a-d)/(1+(x/c)^b)+d;如果b > 0,随着x的增大,y减小,但是你给出的数据显示,y随着x增加而增加
[解决办法]
也就是说你现在
x和y的数据都有了
可以使用cftool可视化工具拟合,
输入
>>cftool;
在curve fitting tool,选择data,分别选择
x数据和y数据分别选择x、y,然后为新集合命名这里设为y vx.x,关闭data框
然后选择fitting,进入,新建拟合New fit,fit name为你拟合的名称,数据集为你刚才的y vx.x,
在type of fit选择custom equations,自定义方程,

custom equations选择New,new custom equations,在general equations输入你的方程,点击OK,退出new custom equations,选择apply进行拟合,
在fitting面板下的


result页可以看到你要求的模型、各未知数计算结果。

热点排行