How to solve for a variable multiple times using a for loop.
Show older comments
I need to solve a nonlinear equation multiple times and plot the results. The equation is based on V, which is a constant, T, k & Kc, which both depend on T, and X. I'm trying to plot X as a function of T but can't seem to figure it out. When I attempt to use a for loop, I receive the error "Error using mupadmex Error in MuPAD command: Operands are invalid. [linalg::matlinsolve]".
x=1
for T = [300;1;400]
syms X
V = 3785.411784;
k = 1/2902.149*exp(15000*4.184/8.314*(1/300-1/T))
Kc = 3*exp(-25000*4.184/8.314*(1/300-1/T));
eqn = X/k/((1-X)^2-X^2/Kc)-V == 0;
Solution = double(vpasolve(eqn, X, [0 1]))
Solmat(x,1) = T;
Solmat(x,2) = Solution;
x=x+1;
end
Accepted Answer
More Answers (0)
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!