Simulink Threshold with action
Afficher commentaires plus anciens
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.
Réponses (2)
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
Walter Roberson
le 22 Fév 2025
0 votes
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.
Catégories
En savoir plus sur Sources dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!