How To save the value of time when a condition is met

조회 수: 4 (최근 30일)
Kim Phillips
Kim Phillips 2022년 9월 6일
댓글: Kim Phillips 2022년 9월 11일
Hi,
I am trying to save a value of time when a condition is met. the way I am currently implementing it is saving the array of time rather then the one value I require. My t is generated from a clock block in simulink.
% tM 1st instance of time when alpha1*alpha2 = 1
if (p.alpha1 * p.alpha2 == 1)&& (p.flag2 == 1)
p.tM =t;
p.flag2 = 0;
end
  댓글 수: 6
Mark McBroom
Mark McBroom 2022년 9월 11일
You should not use a mux block. You should feed the digital clock block directly to the MATLAB Function block. Then, p.tM will be set to the current simulation time when the condition is true.
Kim Phillips
Kim Phillips 2022년 9월 11일
Thanks Mark.
p.tM does get set to the simulation time, however it changes as time changes, where as I need it to stay at one value and not change with time. I have extracted all my inputs from the mux block in my function so time is read as it should be inside the function.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by