INDEX EXCEEDS ARRAY BOUNDS

1 回表示 (過去 30 日間)
Kumar Shreyansh
Kumar Shreyansh 2018 年 7 月 18 日
回答済み: Aquatris 2018 年 7 月 18 日
I am plotting NACA airfoil based on the equations. this is the code excerpt where error occurred:
gridPts = 500;
xu = ones(gridPts,1);
yu = ones(gridPts,1);
for i = 1:1:gridPts
xu(i) = x(i) - yt(i)*sin(theta(i));
yu(i) = yc(i) + yt(i)*cos(theta(i));
end
Please advise. this is for my class project. I am using 2018a.
  1 件のコメント
Geoff Hayes
Geoff Hayes 2018 年 7 月 18 日
編集済み: Geoff Hayes 2018 年 7 月 18 日
Kumar - what is the full error message? The problem may be with yt since I don't see anywhere in the code where this variable is intialized. The others appear to be initialized with gridPts so should have the correct dimensions...

サインインしてコメントする。

回答 (1 件)

Aquatris
Aquatris 2018 年 7 月 18 日
In your code you have slight mistake, where you forgot to assign to an index but instead overwrite the variable ("(i)" is the fix);
%Thickness distribution
yt = ones(gridPts,1);
for i = 1:1:gridPts
yt(i) = 5*T*(a0*sqrt(x(i)) + a1*x(i) + a2*x(i)^2 + a3*x(i)^3 + a4*x(i)^4);
end

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by