Solve equation with multiple values for V
Afficher commentaires plus anciens
Hi, i'm trying so solve an equation with 19 different values for V and Pv. It's possible when i do it one at a time, but not when I'm trying with a loop.
Vr=12;
Vi=3;
Pr=max(P_test_data4);
Pv=P_test_data4;
V=WS_test_data4;
syms n
for i=0:length(WS_test_data4);
solve((Pr*((V.^n)-(Vi.^n)))/((Vr.^n)-(Vi.^n))==Pv,n)
end
V=3.53;
Pv=73;
solve((Pr*((V^n)-(Vi^n)))/((Vr^n)-(Vi^n))==Pv,n)
The abbove code does'nt give an answer just " Empty sym: 0-by-1 "
The correct for the first one should be:
V=3.53;
Pv=73;
solve((Pr*((V^n)-(Vi^n)))/((Vr^n)-(Vi^n))==Pv,n)
ans = 2.6088704281837088027315795939332
Thanks in advance
CODE:
Vr = 12;
Vi = 3;
Pr = 5000;
syms n
V = [3;3.5;4;4.51;5;5.5;6;6.5;7;7.5;8.01;8.5;9;9.5;10;10.49;10.99;11.49;12]
Pv = [13;73;201;385;619;864;1174;1508;1894;2271;2710;3150;3523;3918;4244;4496;4711;4834;5000]
for i = 1:length(V)
n = vpasolve((Pr*((V.^n)-(Vi.^n)))/((Vr.^n)-(Vi.^n))==Pv,n)
end
n = mean(n)
Réponse acceptée
Plus de réponses (1)
Matt J
le 24 Oct 2021
0 votes
Because there is no analytical solution. Try vpasolve() or fzero() instead.
1 commentaire
Alexander Madsen
le 25 Oct 2021
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!