Input Argument is "undefined"
2 次查看(过去 30 天)
显示 更早的评论
Currently I am trying to fit a function to a set of data by solving for two parameters using the FMINSEARCH command.
This is the code:
function sse = LogisticRegression2(x,t,Actual_Output)
fileName = 'Altered Intensity data(red)_2009-01-16 to -22';'G-SNP20 red';
a = xlsread(fileName);
t = a(:,1); %t values of the data set I am trying to fit
I = a(:,2)/max(a(:,2)); %the y coordinate data points of the data set
lambda = x(1); %one of the parameters
Km = x(2); %the second parameter
Rt = 5e-11;
cm0 = 3e-9;
epsilon = Rt/cm0;
L1 = (1+Km+epsilon)/(2*epsilon)*(1+sqrt(1-(4*epsilon)/(1+Km+epsilon)^2));
L2 = (1+Km+epsilon)/(2*epsilon)*(1-sqrt(1-(4*epsilon)/(1+Km+epsilon)^2));
Fitted_Curve = (L1*L2*(1-exp(-epsilon*(L1-L2)*t*60/lambda)))/(L1-L2*exp(-epsilon*(L1-L2)*t*60/lambda));
Error_vector = Fitted_Curve-Actual_Output;
sse = sum(Error_vector.^2);
Starting=rand(4e3,.01);
options=optimset('Display','iter');
x = fminsearch(@LogisticRegression,Starting,options,t,I);
% To check the fit
plot(t,I,'*')
hold on
plot(t,x(1)*exp(-x(2)*t),'r')
However I am getting an error of
"Input argument "x" is undefined.
Error in ==> LogisticRegression2 at 7
lambda = x(1); %one of the parameters"
I am not sure what I did wrong. If anyone knows what went wrong I would greatly appreciate it. Thanks
Thomas
1 个评论
回答(2 个)
Jan
2011-10-13
It looks like you are calling LogisticRegression2 without inputs, but this function needs 3 inputs. The Getting Started chapters of the documentation explain the usage of functions exhaustively.
0 个评论
Thomas
2011-10-13
1 个评论
Jan
2011-10-13
I cannot answer the question, how you are calling this function - but you can! Please post the line, which calls the function. The error message says, that the first input argument x has not been defined.
You have t in the inputs, but overwrite it in the function.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!