Why Matrix dimensions do not agree?

5 views (last 30 days)
This is my script:
function Langner_Ue1
load data1 P v;
Vmax3 = 4;
S2 = 40-P;
Km3 = 3;
k1 = 30;
P0 = [Vmax3, Km3, k1];
lsqcurvefit(@Michaelis_Menten_Substratinhibierung_2, P0, S2, v)
figure(2)
plot(S2,v,'r*')
hold on
plot(S2,vMMI2,'r')
hold on
legend('v über S', 'MMI2 über S')
end
function MMI2 = Michaelis_Menten_Substratinhibierung_2(Vmax3, S2, Km3, k1)
MMI2 = (Vmax3.*S2)./(Km3+S2+(S2.^2./k1));
end
Matrix dimensions must agree.
Error in Langner_Ue1>Michaelis_Menten_Substratinhibierung_2 (line 40) MMI2 = (Vmax3.*S2)./(Km3+S2+(S2.^2./k1));
Error in lsqcurvefit (line 213) initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Error in Langner_Ue1 (line 30) lsqcurvefit(@Michaelis_Menten_Substratinhibierung_2, P0, S2, v)
Caused by: Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
If I perform the function 'Michaelis_Menten_Substratinhibierung_2' directly in the command window there is no failure and verything works fine. Why do I get a failure when I try to run the script?
  4 Comments
madhan ravi
madhan ravi on 4 Nov 2018
upload your file by clicking the paper clip button

Sign in to comment.

Accepted Answer

Bruno Luong
Bruno Luong on 4 Nov 2018
Edited: Bruno Luong on 4 Nov 2018
Try this:
load data1 P v;
Vmax3 = 4;
S2 = 40-P;
Km3 = 3;
k1 = 30;
P0 = [Vmax3, Km3, k1];
P = lsqcurvefit(@Michaelis_Menten_Substratinhibierung_2, P0, S2, v);
MMI2 = Michaelis_Menten_Substratinhibierung_2(P, S2);
figure(2)
plot(S2,v,'r*')
hold on
plot(S2,vMMI2,'r')
hold on
legend('v über S', 'MMI2 über S')
end
function MMI2 = Michaelis_Menten_Substratinhibierung_2(P, S2)
Vmax3 = P(1);
Km3 = P(2);
k1 = P(3);
MMI2 = (Vmax3.*S2)./(Km3+S2+(S2.^2./k1));
end
  3 Comments
Bruno Luong
Bruno Luong on 4 Nov 2018
In any optimization function you have to provide the parameters as a vector, up to you to split the vector in a meaningful way.
I just guess because you supply
P0 = [Vmax3, Km3, k1];
So the order of parameters must be as written in Michaelis_Menten_Substratinhibierung_2.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics 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!