Solve matrix in the equation

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일

0 개 추천

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일

0 개 추천

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)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2013년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by