Input Argument is "undefined"
2 views (last 30 days)
Show older comments
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 Comment
Answers (2)
Jan
on 13 Oct 2011
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 Comments
Thomas
on 13 Oct 2011
1 Comment
Jan
on 13 Oct 2011
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.
See Also
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!