フィルターのクリア

For Loop is only running once

2 ビュー (過去 30 日間)
Ryan Bowman
Ryan Bowman 2019 年 2 月 13 日
編集済み: aara 2019 年 2 月 13 日
My for loop is only running one time and M_Star2 and M_Star should be a 1x41 matrix but it only comes out as one number. Here is my code: Solution??
clc
clear workspace
gamma = 1.4;
M = 3:0.1:7;
for ii = 1:size(M);
P_staticRATIO = 1 + (2*gamma/gamma+1)*((M.^2)-1);
P_stagRATIO = (((((gamma+1)^2)*M.^2)/(4*gamma.*(M.^2))-2*(gamma-1)).^3.5)*(((-.4)+2*gamma.*M.^2)/2.4);
M_star2 = ((gamma+1).*M.^2)/(2+(gamma-1).*M.^2);
M_star = sqrt(M_star2);
plot(P_staticRATIO,P_stagRATIO,P_staticRATIO,M_star);
legend('Stagnation Pressure Ratio','M*')
title('M* & Stagnation Pressure Ratio as a Funciton of Static Pressure Ratio')
xlabel('Static Pressure Ratio')
ylabel('M*, Stag. Pressure Ratio')
end

採用された回答

aara
aara 2019 年 2 月 13 日
編集済み: aara 2019 年 2 月 13 日
the size function returns a vector [1 41] which is why the loop only runs once.
Use:
for ii = 1:max(size(M));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by