Solving for multiple solutions and plotting them
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
By choosing one value to theta2 I'm able to solve for one solution of beta and then use it to calculate P2.
What Id like to do is solve for multiple solutions of beta and then use those to find the correstpoing P2 (pressure 2).I tried making theta2 an array but it does not work.
Once thats complete I want to plot all angles and the correspoinding pressure 2(P2).
The code works if i just set theta 2 to some interger but when i want to make it an array to solve for many Beta which i need to solve for P2s i get an error. HELP
clc
clear all
format short g
M1 = 3;
P1 = 1;
theta2 = 1:1:20;
gamma = 1.4;
phi = 4.8;
syms beta2
tantheta2 = tand(theta2);
x = 2*cotd(beta2)*((M1^2*((sind(beta2))^2)-1));
y = M1^2*(gamma+cosd(2*beta2))+2;
eqn2 = x/y;
b0=1;
result2 = vpasolve(tantheta2 == eqn2, beta2,b0);
beta2 = vpa(result2);
Mn1 = M1*sind(beta2);% Eqn 4.7 from Anderson's
p2p1 = 1+((2*gamma)/(gamma+1))*(Mn1^2-1);% Eqn 4.9 from Anderson's
Mn2sq = (Mn1^2+(2/(gamma-1)))/((2*gamma/(gamma-1))*Mn1^2-1);% Eqn 4.10 from Anderson's
Mn2 = sqrt(Mn2sq);
M2 = Mn2/sind(beta2-theta2);
P2 = p2p1*P1;
0 Commenti
Risposte (1)
Sulaymon Eshkabilov
il 26 Ott 2021
Modificato: Sulaymon Eshkabilov
il 26 Ott 2021
Here is the corrected code:
clc; clearvars
format short g
M1 = 3;
P1 = 1;
theta2 = 1:1:20;
gamma = 1.4;
phi = 4.8;
syms beta2
tantheta2 = tand(theta2);
x = 2*cotd(beta2)*((M1^2*((sind(beta2)).^2)-1));
y = M1^2*(gamma+cosd(2*beta2))+2;
eqn2 = x/y;
b0=1;
for ii=1:numel(theta2)
T = tantheta2(ii);
clearvars result2
syms beta2
result2 = vpasolve(T== eqn2, beta2,b0);
beta2 = vpa(result2);
Mn1 = M1*sind(beta2); % Eqn 4.7 from Anderson's
p2p1 = 1+((2*gamma)/(gamma+1))*(Mn1^2-1); % Eqn 4.9 from Anderson's
Mn2sq= (Mn1^2+(2/(gamma-1)))/((2*gamma/(gamma-1))*Mn1^2-1);% Eqn 4.10 from Anderson's
Mn2 = sqrt(Mn2sq);
M2 = Mn2/sind(beta2-theta2(ii));
P2 = p2p1*P1;
P2_ALL{ii}=P2;
end
1 Commento
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!