How schould the matlab function be to hold an signal between two values?
1 view (last 30 days)
I have a rising signal of a temperature. As long as the value has not reached a limit, e.g. 90%, "0" is to be displayed. If the value is reached, 1 is displayed. After that, the value can drop to e.g. 30% until "0" is output again. This is to achieve that the value remains between the two limits by the output of 0 and 1.
It is about a Simulink model and the code for it should be in a matlab-fct block.
I tried a lot with if-functions but i dont get it.
Les Beckham on 7 Oct 2022
Edited: Les Beckham on 7 Oct 2022
Perhaps something like this in a MATLAB Function block?
function out = determineStatus(in)
out = 0; % initial output value
% implement the hysteresis
if out = 0 && in > 90
out = 1;
elseif out = 1 && in < 30
out = 0;