hi,i wrote this code:
syms f te t1 p2 t2 t3 p3 p4 t4 t5 f1 t6
for f= 0.035:0.001:0.06
for te= 1800:1:2500
t1=(1-f)*300+f*(1-((1-50)/100)*((1.3-1)/1.3))*te
p2=50*(10)^1.3
t2=t1*10^0.3
t3=t2+2500*(1-f)/0.775
p3=p2*(t3/t2)
p4=p3*(1/10)^1.3
t4=t3*(1/10)^0.3
t5=t4*((p4/100)^(0.3/1.3))
f1=((100/p4)^(1/1.3))/10
t6=(1-f1)*300+f1*(1-((1-50)/100)*((1.3-1)/1.3))*t5
if ((abs((t6-t1)/t1)*100)<3) && ((abs((f-f1)/f)*100)<3) && ((abs((te-t5)/te)*100)<3)
table(t1,t6,f,f1,te,t5)
break
end
end
end
i want it to stop at certain point so i used Break but it continued and didin't break.
why?

1 件のコメント

Image Analyst
Image Analyst 2020 年 12 月 3 日
Please highlight your code in MATLAB and type control-a (to select all) then control-i (to properly indent it). Then paste it back here and highlight it and click the "Code" icon on the tool ribbon. this will ensure your code doesn't look like a total mess to us and will make it easy for us to copy into the clipboard. Also be sure to see Start Strider's Answer below.

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

 採用された回答

Star Strider
Star Strider 2020 年 12 月 3 日

0 投票

You have two nested loops. The break command will only break out of the inner loop, the one it is called in.
A simple example —
for k1 = 1:6
for k2 = 1:4
k_2 = k2;
fprintf('\t\tk_2 = %d\n', k_2)
if k2 > 2
break
end
end
fprintf('k1 = %d\tk2 = %d\n', k1, k_2)
end
.

4 件のコメント

arsalan mehrabi
arsalan mehrabi 2020 年 12 月 4 日
編集済み: arsalan mehrabi 2020 年 12 月 4 日
so i should write another break and it'll solve my probelm ?
can you please give me a example?
Star Strider
Star Strider 2020 年 12 月 4 日
i am not certain what you want to do.
Consider using the return function instead.
arsalan mehrabi
arsalan mehrabi 2020 年 12 月 6 日
thanks, it worked when i used return.
Star Strider
Star Strider 2020 年 12 月 6 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by