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 Center および File ExchangeSources についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by