Solve matrix in the equation

2 次查看(过去 30 天)
Redwood
Redwood 2013-4-30
Dear Matlab experts,
I would like to get b values, but I think my coding is wrong. Please let me know how to get the b values.
syms b G = [7340, 7194]; G1 = [4516.881,5002.953]; M1 =[ 5222.328, 6009.419]; M2 =[3264.034, 2632.621]; P1 =[3000, 3025]; P2 =[10000, 10051]; Out=solve(G1 == G*(P1*exp(-b*M1/P1)/( P1*exp(-b*M1/P1)+ P2*exp(-b*M2/P2))), b) Out=double(out)
Thank you very much in advance.
Sincerely yours,
Redwood

回答(2 个)

Roger Stafford
Roger Stafford 2013-4-30
You can't use the 'solve' function with vector inputs in that manner. You should leave all six parameters as symbols and let 'solve' obtain a general solution for 'b' as a function of them. Then use matlab to evaluate this function for your vector inputs.
Actually you don't even need 'solve' in this very elementary case. You can solve it yourself with simple algebra. The following equations are equivalent:
G1 = G*(P1*exp(-b*M1/P1)/(P1*exp(-b*M1/P1)+ P2*exp(-b*M2/P2)))
G1/G = 1/(1+P2/P1*exp(-b*(M2/P2-M1/P1)))
P2/P1*exp(-b*(M2/P2-M1/P1)) = G/G1 - 1
exp(-b*(M2/P2-M1/P1)) = (G/G1-1)*P1/P2
-b*(M2/P2-M1/P1) = log((G/G1-1)*P1/P2)
b = -log((G/G1-1)*P1/P2)/(M2/P2-M1/P1)
This last equation is your general solution for b in terms of the six parameters, so evaluate it directly with matlab:
b = -log((G./G1-1).*P1./P2)./(M2./P2-M1./P1);

Zhang lu
Zhang lu 2013-5-1
编辑:Zhang lu 2013-5-1
syms b G G1 M1 M2 P1 P2
Out=solve('G*(P1*exp(-b*M1/P1)/( P1*exp(-b*M1/P1)+ P2*exp(-b*M2/P2)))-G1', b)
G = [7340, 7194];
G1 = [4516.881,5002.953];
M1 =[ 5222.328, 6009.419];
M2 =[3264.034, 2632.621];
P1 =[3000, 3025];
P2 =[10000, 10051];
Out=subs(Out)

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by