Division from different For loop
2 views (last 30 days)
Show older comments
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:)
0 Comments
Answers (1)
Ameer Hamza
on 10 Mar 2020
Edited: Ameer Hamza
on 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;
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!