"brake" not working in Matlab 2021b - is there a fix or work around?

1 ビュー (過去 30 日間)
William Farrell
William Farrell 2022 年 6 月 20 日
コメント済み: William Farrell 2022 年 6 月 20 日
Here is the block of code:
-------------------------------------------------------------------------------------------
while (times(index) <= stime)
index = index + 1;
if index > x
index = 1;
end
if (times(index) > stime)
brake
end
tt(index) = times(index);
qq1(index) = qip1(index);
qq2(index) = qip2(index);
qq3(index) = qip3(index);
qq4(index) = qip4(index);
YY(index) = OGA(index);
ZZ(index) = IGA(index);
end
---------------------------------------------------------------------------------------------------------
Obviously I'm reading a file and loading quantities into variables and I don't want to read the file past a time named "stime". When (times(index) <= stime) is true and the execution hits "break" I get the following error and Matlab stops:
"Unrecognized function or variable 'brake'.
Error in rdtraj (line 70)
brake"
But "brake" is in the documentation with the following example:
----------------------------------------------------------
limit = 0.8;
s = 0;
while 1
tmp = rand;
if tmp > limit
break
end
s = s + tmp;
end
------------------------------------------------------------------
Thank you.

回答 (2 件)

Geoff Hayes
Geoff Hayes 2022 年 6 月 20 日
@William Farrell - the keyword is break not "brake".
  1 件のコメント
William Farrell
William Farrell 2022 年 6 月 20 日
Thank you!

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


Fangjun Jiang
Fangjun Jiang 2022 年 6 月 20 日
"break", not "brake"
  3 件のコメント
William Farrell
William Farrell 2022 年 6 月 20 日
Yep. All I can do is laugh at myself! Thanks everyone.

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

カテゴリ

Find more on Loops and Conditional Statements in Help Center and File Exchange

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by