Why Matrix dimensions do not agree?

1 次查看(过去 30 天)
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 个评论
madhan ravi
madhan ravi 2018-11-4
upload your file by clicking the paper clip button

请先登录,再进行评论。

采纳的回答

Bruno Luong
Bruno Luong 2018-11-4
编辑:Bruno Luong 2018-11-4
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 个评论
Bruno Luong
Bruno Luong 2018-11-4
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by