Simulink Threshold with action
3 views (last 30 days)
Show older comments
I would like to create a simulink model that basically takes an input, lets say 2.5, and check if this value is between 6.5 to 8.5. Once checked, if below this range, then it must add 1 to the initial input. If it is betwen this range, all it needs to do is display the output that falls between the 6.5 to 8.5 range. If possible, I would like for it to show how many iterations it took to get between range.
0 Comments
Answers (2)
Sam Chak
on 22 Feb 2025
Naturally, I would expect that the input signal evolves over time and that the thermostat-like controller performs a switching action to maintain the signal within a specified band.
However, the way you described the requirement suggests a discrete event. Consequently, it is relatively straightforward to calculate the number of iterations required mentally.
numIteration = 0;
input_Signal = 2.5;
desiredState = 6.5;
%% as if you would calculate in mind
number_of_iterations = desiredState - input_Signal
%% switching action
while input_Signal < desiredState
switchAction = 1; % constraint of the controller
input_Signal = input_Signal + switchAction;
numIteration = numIteration + 1; % counter
end
input_Signal
numIteration
0 Comments
Walter Roberson
on 22 Feb 2025
Initialize the input signal. "While" the current signal is less than the desired state, add the increment to the signal and increment a counter. When the condition becomes false, read out the counter.
0 Comments
See Also
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!