I am running a code for blasius equation on a flat plate.

1 回表示 (過去 30 日間)
Jarvis
Jarvis 2018 年 2 月 11 日
コメント済み: Jarvis 2018 年 2 月 11 日
When ever I run the code nothing even shows in my workspace. How do I fix this please? I tried to use m=o, and m=m+1. How do I have matlab stop the loop after a certain number iterations?
x= 0.05:0.05:1;
spacing=0.001;
eta=0:spacing:10;
%All y calculated values
for i=1:length(x)
for j=1:length(eta)
y(i,j)=eta(j)*sqrt(x(i)*kinematic_viscosity/Us); %instead of plotting downwards, I am plotting 4 rows
y25= eta(j)*sqrt(0.25*kinematic_viscosity/Us);
y50= eta(j)*sqrt(0.50*kinematic_viscosity/Us);
y75= eta(j)*sqrt(0.75*kinematic_viscosity/Us);
y1= eta(j)*sqrt(kinematic_viscosity/Us);
end
end
while 1
fdoubleprime=A;
for i=1:(length(eta)-1);
f(i+1)=f(i)+spacing*fprime(i);
fprime(i+1)=fprime(i)+spacing*fdoubleprime(i);
fdoubleprime(i+1)=fdoubleprime(i)-((spacing)/2)*f(i)*fdoubleprime(i);
ftripleprime(i+1)=-0.5*(f(i+1))*(fdoubleprime(i+1));
end
errorf=abs(fprime(end)-1)/1;
if errorf<(10^-4)
break
end
if fprime(end)>1
A=A-0.00001;
else
A=A+0.00001;
end
end
for k=1:length(x)
U=Us*fprime;
tauwall(k)=A*sqrt(((dynamic_viscosity)^2*(Us)^3)./(x(k).*kinematic_viscosity));
end
m=m+1

採用された回答

Image Analyst
Image Analyst 2018 年 2 月 11 日
To stop the loop after a certain number of iterations, use break.
loopCounter = 1;
maxIterations = 100000; % Whatever you want.
for ...... % or while ...... however you're doing your looping.
% code in loop...
% At bottom of loop
if loopCounter >= maxIterations
break;
end
loopCounter = loopCounter + 1;
end
  1 件のコメント
Jarvis
Jarvis 2018 年 2 月 11 日
Thanks Image Analyst.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by