フィルターのクリア

How can I call a function every three time steps?

1 回表示 (過去 30 日間)
Asaf McRock
Asaf McRock 2021 年 3 月 27 日
編集済み: Asaf McRock 2021 年 6 月 11 日
I want to call my function every three time steps.
So, at tt = 3,6,9,12,...,tmax I want to call [G] = myfunction(r, Gamma); inside the if statement. And at tt = 1,2,4,5,7,8,... the if statement should be executed but without calling the function.
for tt = 1:tmax
if
...
end
end
I would appreciate your thoughts and ideas.
Thanks

採用された回答

DGM
DGM 2021 年 3 月 27 日
Something like this:
for tt=1:20
if ~mod(tt,3)
% do special stuff in this case
disp('tt is a multiple of 3')
end
% do normal stuff every time
end
  1 件のコメント
Asaf McRock
Asaf McRock 2021 年 3 月 27 日
Thank you so much.

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

その他の回答 (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