- Solve - https://www.mathworks.com/help/symbolic/solve.html
- Subs - https://www.mathworks.com/help/symbolic/subs.html
- Functions for rearranging expressions - https://www.mathworks.com/help/symbolic/choose-function-to-rearrange-expression.html
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How can I make a variable that is a matrix correctly output another matrix in a symbolic function?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I ahve two 1x300 matrix variables that i need to plug into a function , but every time I solve it I end up with a 0x1 matrix. How can i fix this issue? I was also wondering if a for loop is more suitable for solving it. This is my code so far. Thank you
clear('all'),clc
p_rng = logspace(-2,2,300); % [MPa] pressure (p) range
t_rng = 273.15+linspace(1,800,300); % [K] temperature (T) range
a=40100;
b=1.60;
R=10.73159;
syms V
eqn1= p_rng==((R*t_rng)/(V-b))-((a)/((V*(V+b))+(b*(V-b))));
V=solve(eqn1,V);
0 Kommentare
Antworten (1)
Surya Talluri
am 6 Aug. 2020
I understand that you directly used 1x300 sized matrix to create the symbolic equation. I substituted the variables after rearranging the equation and then solved the equations.
syms V p_rng t_rng a b R
eqn1= ((R*t_rng)/(V-b))-((a)/((V*(V+b))+(b*(V-b)))) == p_rng;
eqn1 = collect(eqn1, V);
simple_eqn1 = simplify(eqn1)
As you can see that above equation contains 2 expressions, one of them is an expression which shows denominator is not equal to 0.
S = solve( simple_eqn1, V, 'ReturnConditions',true);
S = subs(S.V, {a, b, R, p_rng, t_rng}, {40100, 1.60, 10.73159, logspace(-2,2,300), 273.15+linspace(1,800,300)});
soluntion = vpa(S);
You can refer to following documentation for further information:
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!