Input Argument is "undefined"

조회 수: 3 (최근 30일)
Thomas
Thomas 2011년 10월 13일
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
Jan
Jan 2011년 10월 13일
Please format your code - follow the "Markup help" link for details.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jan
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.

Thomas
Thomas 2011년 10월 13일
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
Jan
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 CenterFile 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!

Translated by