Different sizing on LHS and RHS
Afficher commentaires plus anciens
Hi there, I'm wondering if anyone could explain why this error is happening. My code is not solving the full 100 iterations when solving for Ma1. It only reaches a value of i=98 in the for loop solving for ma1. Is there a reason it is stopping? or is there a way to make it solve all 100? I don't understand why it has an upper cap.
When I set TL to 1.8, the solution runs perfectly fine, but when I move it to 1.9 or higher it does not solve all the values of Ma1.
%set variables
To = 330;
MF_max = 0.2;
L_max= 2.1;
G = 1.4;
R = 287;
f = 0.003;
Po = 4;
TL = 2; % we can change this one
%PSW = 0.4; % location of pipe in realtion to total pipe length (m)
PSW = linspace(0.36,0.69); % min distance of shockwave in realtion to total pipe length
AL = length(PSW);
%PSW = 0.69 % max distance of shockwave in realtion to total pipe length
L12 = PSW*TL;
D = 0.03; % we can change this one too
Ma4 = 1;
P4 = 1.013;
Lc3 = TL-L12;
FLcD3 = 4*f*Lc3/D;
syms ma3
Ma3a = [];
for i = 1:1:AL
eqn1 = (-1./G).*(1-ma3.^-2)+((G+1)./(2.*G)).*log((((G+1)./2).*ma3.^2)./(1+((G-1)./2).*ma3.^2)) == FLcD3(i);
Ma3a(1,i) = vpasolve(eqn1,ma3,0.01);
end
Ma3 = Ma3a;
syms ma2
Ma2a = [];
for i = 1:1:AL
eqn2 = ((1+((G-1)./2).*ma2.^2)./(G.*ma2.^2-((G-1)./2))).^0.5 == Ma3(i);
Ma2a(1,i) = vpasolve(eqn2,ma2,[1 100]);
end
Ma2 = Ma2a;
FLcD2 = (-1./G).*(1-Ma2.^-2)+((G+1)./(2.*G)).*log((((G+1)./2).*Ma2.^2)/(1+((G-1)./2).*Ma2.^2));
FL12D = 4.*f.*L12./D;
FLcD1 = FLcD2 + FL12D;
syms ma1
Ma1a = [];
for i = 1:1:AL
eqn3 = (-1./G).*(1-ma1.^-2)+((G+1)./(2.*G)).*log((((G+1)./2).*ma1.^2)./(1+((G-1)./2).*ma1.^2)) == FLcD1(i);
Ma1a(1,i) = vpasolve(eqn3,ma1,1.1);
end
Ma1 = Ma1a;
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics 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!