i want to iterate for each crack size from 25 to 250mpa with 25 increments

3 ビュー (過去 30 日間)
Hasan
Hasan 2024 年 12 月 21 日
コメント済み: Hasan 2024 年 12 月 21 日
I want to iterate for every load from 25 to 250 mpa with 25 increments but i didn't take conclusion. here my code and please help me;
clc
clear all
close all hidden
W = 0.4;
Sy = 250;
ea = 0.001;
Es = 0;
i=1;
fprintf('%10s %10s %10s\n','Load','K1eff Irwins app.','At iteration no');
for S = 25
S = S+25;
while abs(Es)<ea
i=i+1;
aold = 0.0254;
x1 = aold/W;
bold = 1+0.256.*x1-1.152.*x1.^2+12.2.*x1.^3;
kold = bold.*S.*(pi.*aold).^1/2;
rp = (1/(2.*pi)).*(kold./Sy).^(2);
anew = aold + rp;
x2 = anew./W;
bnew = 1+0.256.*x2-1.152.*x2.^2+12.2.*x2.^3;
knew = bnew.*S.*(pi.*anew).^(1/2);
Es = abs((knew-kold)./knew).*100;
if Es >= 0.0001
anew = aold;
end
fprintf('%10.4f %10.4f [%10.4f]\n', S, knew, i)
end
if S==250
break
end
end

回答 (1 件)

Walter Roberson
Walter Roberson 2024 年 12 月 21 日
for S = 25 : 25 : 250

and get rid of the S=S+25 and the test for S==250

  3 件のコメント
Walter Roberson
Walter Roberson 2024 年 12 月 21 日
while abs(Es)<ea
Nothing in your for loop changes Es or ea. Once abs(Es)<ea becomes false, nothing resets Es or ea, so the test will continue to be false on the next iteration (and the iteration after that...)
You probably need to move the
Es = 0;
inside the for loop.
Hasan
Hasan 2024 年 12 月 21 日
Ohh! it is working. Thank you Walter for your attention. :)

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

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by