Solve matrix in the equation
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (2)
Roger Stafford
le 30 Avr 2013
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);
0 commentaires
Zhang lu
le 1 Mai 2013
Modifié(e) : Zhang lu
le 1 Mai 2013
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)
0 commentaires
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!