Simulink Threshold with action

조회 수: 3 (최근 30일)
Todd
Todd 2025년 2월 22일
답변: Walter Roberson 2025년 2월 22일
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.

답변 (2개)

Sam Chak
Sam Chak 2025년 2월 22일
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
number_of_iterations = 4
%% switching action
while input_Signal < desiredState
switchAction = 1; % constraint of the controller
input_Signal = input_Signal + switchAction;
numIteration = numIteration + 1; % counter
end
input_Signal
input_Signal = 6.5000
numIteration
numIteration = 4

Walter Roberson
Walter Roberson 2025년 2월 22일
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.

카테고리

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