フィルターのクリア

Command for Stopping the Analysis

2 ビュー (過去 30 日間)
Chaudhary P Patel
Chaudhary P Patel 2023 年 5 月 22 日
コメント済み: Image Analyst 2023 年 5 月 26 日
When a variable (x) exeed the limit value (y) doing so after 5 times then stop the analysis.
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 5 月 22 日
Are you using a loop to update the variable (x) or check if x>y? If so, then you can use break.

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

採用された回答

Image Analyst
Image Analyst 2023 年 5 月 22 日
Try something like this
exceedCount = 0;
for k = 1 : 1000000
% First update x in the loop. Then compare it to y.
if x > y
% x is greater than y.
% Increment the count of how many times this has happened.
exceedCount = exceedCount + 1;
% Quit loop if x has exceeded y 5 times.
if exceedCount >= 5
break;
end
end
end
  7 件のコメント
Chaudhary P Patel
Chaudhary P Patel 2023 年 5 月 26 日
Sir @Image Analyst, for my analsis requirement i have to consider the u0<ut && u0>uc for the same loop using elseif condition.
Then where i should use the exceedCount?
Image Analyst
Image Analyst 2023 年 5 月 26 日
Seems inefficient, but you can do
exceedCount = 0;
for k = 1 : 1000000
% First update x in the loop. Then compare it to y.
if (u0 < ut) && (u0 > uc) % Signal is above min and below max.
% u0 is in the acceptable range.
% Do whatever.
else
% u0 is out of the acceptable range.
% Increment the count of how many times this has happened.
exceedCount = exceedCount + 1;
% Quit loop if x has exceeded y 5 times.
if exceedCount >= 5
break;
end
end
end
To learn other fundamental concepts, invest 2 hours of your time here:

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by