How to solve for all 5 values of x?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mary Jean Savitsky
am 10 Apr. 2020
Kommentiert: Star Strider
am 10 Apr. 2020
T= (473:50:673);
K=exp(21.225+(9143.6./T)-(7.492*log(T))+((4.076*10^-3)*(T))-(7.161*10^-8).*(T).^2);
syms x
function
eqn= ((100*x-2*x^2)/(1625-115*x+2*x^2))==K(1)*(5476);
solx= solve(eqn,x)
I want to solve for all the different values of x (there should be 5) using each different value of K. I tried just using K as a variable but gave me an error so I was going to do each individual K using K(1), K(2), etc. but it gives me a funciton instead of a value. please help!
0 Kommentare
Akzeptierte Antwort
Star Strider
am 10 Apr. 2020
I would use a loop:
T= (473:50:673);
K=exp(21.225+(9143.6./T)-(7.492*log(T))+((4.076*10^-3)*(T))-(7.161*10^-8).*(T).^2);
syms x
for m = 1:numel(K)
eqn= ((100*x-2*x^2)/(1625-115*x+2*x^2))==K(m)*(5476);
solx(:,m) = vpasolve(eqn,x);
end
to store the results as columns of ‘solx’.
If you want to use them in numeric applications, use:
soln = double(solx);
2 Kommentare
Star Strider
am 10 Apr. 2020
Thank you!
I don’t understand. The ‘solx’ and ‘soln’ matrices are (2x5), with every column being a solution for a different value of ‘T’. (This is true in R2020a, however it should be the same in recent earlier releases as well.)
To plot them:
figure
plot(T, soln)
grid
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!