Division from different For loop

5 vues (au cours des 30 derniers jours)
Sun Kyoo Choi
Sun Kyoo Choi le 9 Mar 2020
Modifié(e) : Ameer Hamza le 10 Mar 2020
Hi all,
I was wondering if I could divide two arrays or matrix from distinct for loop with a correct dimension.
For example,
gamma = 1.4;
R = 287;
p1 = [6.78,2.79,9.8,11.93,7.81,8.83,5.81,7.84,5.29,4.83,9.77];
T1 = [23,23,22.5,23,22,22,22,22.5,24.5,22.5,24];
for K = 1:length(p1)
p4 = 29.85;
fun = @(p2) p2/p4*(1 -((gamma-1)*(p2/p1(K)-1))./(2*gamma*(2*gamma+(gamma+1)*(p2/p1(K)-1))).^.5).^(-2.*gamma./(gamma-1))-1;
result(K) = fzero(fun,10)/p1(K) ;
end
for i = 1:length(T1)
fun1 = @(T2) (result(K)*T1(i)/T2)*(((gamma+1)/(gamma-1))+result(K))/(1+(((gamma+1)/(gamma-1))*result(K)))-1;
Temp(i) = fzero(fun1,25);
end
for Q = 1:length(T1)
a(Q) = sqrt(gamma*R*T1(Q));
end
M_s = w_s(j)./a(Q); => % this is my final goal, M_s, that I would like to get at the end. Both a(Q) and w_s(j) are 1x11 so that
%it has to give me 1x11 matrix after a division. However, for some reason, it only gives me 1x1 matrix. Is there any way
%to get a proper answer with a proper dimension? Thank you:)

Réponses (1)

Ameer Hamza
Ameer Hamza le 10 Mar 2020
Modifié(e) : Ameer Hamza le 10 Mar 2020
w_s and a are 1x11. Whereas you are dividing w_s(j) and a(Q) which are 1x1. Use
M_s = w_s./a;

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by