Set and reset Simulink

조회 수: 1 (최근 30일)
Adam Keller
Adam Keller 2015년 7월 26일
댓글: Adam Keller 2015년 7월 26일
Hello,
I am having trouble regarding value holding and reset with a simulink function. When a condition occurs I would like to have that value held until an external reset occurs.
Ex)
if x==7
z = 6; % but z stays at 6 even after x does not equal 7
elseif reset ==1 %reset occurs
z = 0;
end
I would like to trigger a value, hold, use an external signal to reset, and then allow to trigger again. Is there a block that can do this?
Many thanks.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 26일
편집: Azzi Abdelmalek 2015년 7월 26일
Try this
function z=fcn(x,reset)
persitent xx
if isempty(xx)
xx=0
end
if (x==7|xx==1) & reset==0
z = 6;
xx=1;
elseif reset==1
z = 0;
xx=0
end
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 26일
Adam Keller
Adam Keller 2015년 7월 26일
That's what I meant, my apologies. Thank you Azzi!

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by