필터 지우기
필터 지우기

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by