Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How can I make a variable that is a matrix correctly output another matrix in a symbolic function?

1 visualizzazione (ultimi 30 giorni)
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);

Risposte (1)

Surya Talluri
Surya Talluri il 6 Ago 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:

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by