Using if function for 'for statement'

1 回表示 (過去 30 日間)
Gokay Karatas
Gokay Karatas 2019 年 10 月 11 日
回答済み: KALYAN ACHARJYA 2019 年 10 月 11 日
Hello everyone,
I have defined X values between 0 to 3 by steps of 0.1, and function is working for each statement, and for each values I have get .mat files as results for the post processing.
However, I need some help to make the code a bit more smarter like if there is negative values in .mat files, matlab should stop to operate. Is it possible put if in for function?

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 10 月 11 日
X=0:0.1:3;
% Define X as per requirements
for i=1:length(X)
if X(i)<0
break;
else
% do operation to get mat file for X(i);
% as you mentioned in the question
end
end

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by