Input Argument is "undefined"

3 visualizzazioni (ultimi 30 giorni)
Thomas
Thomas il 13 Ott 2011
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 Commento
Jan
Jan il 13 Ott 2011
Please format your code - follow the "Markup help" link for details.

Accedi per commentare.

Risposte (2)

Jan
Jan il 13 Ott 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.

Thomas
Thomas il 13 Ott 2011
Aren't I calling LogisticRegression2 with inputs (x,t,Actual_output)? Where x is defined by the vectors lambda = x(1) and Km = x(2)?
  1 Commento
Jan
Jan il 13 Ott 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.

Accedi per commentare.

Categorie

Scopri di più su Get Started with Curve Fitting Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by