Not Sure How I'm Getting "Subscript indices must either be real positive integers or logicals"
Mostrar comentarios más antiguos
Here is my code, it is an iterative solution to an equation, and I keep getting the error which occurs in the denom(i) line: Subscript indices must either be real positive integers or logicals
g1=1.4;
g4=1.4;
T1=300;
T4=300;
p4p1=5;
R=287;
a1=sqrt(g1*R*T1);
a4=sqrt(g4*R*T4);
ratio= [1.01:.0001:10];
exponent=-2*g4/(g4-1);
numer=ratio;
denom=numer;
temp=denom;
for i=1:length(ratio)
numer(i)=(g4-1)*(a1/a4)*(ratio(i)-1);
denom(i)=sqrt(2*g1((2*g1)+(g1+1)*((ratio(i)-1))));
temp(i)=ratio(i)*((1-(numer(i)/denom(i)))^(exponent));
if abs(temp(i)-p4p1)<.01
p2p1=ratio(i);
break;
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!