how to change suddenly dropping output by a gradually dropping output?

3 ビュー (過去 30 日間)
Lucky
Lucky 2020 年 8 月 20 日
コメント済み: Fangjun Jiang 2020 年 8 月 21 日
I am using simulink matlab function to process some inputs and create an output as shown
Here, as shown in the graph I don,t want a step decrease(marked with blue
arrow). Instead I need it follow a slope and go down gradually. This is changed by the 'x2' input in the simulink figure shown above which right now is just a constant block. This block gets activated only when the condition mentioned in the code below is fulfilled and also this height can vary dependng on the different inputs. In nutshell I can only predict the starting point of the red line (top one) and then it should go down to other point on its own.
function y = Signal_gain(Kr,x,x1,x2,x3)
if (Kr<x1)
u = 1;
elseif (Kr>x1)&&(Kr<0)
u = x2;
else
u = x3;
end
y = u*x;
end

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 8 月 21 日
The Rate Limiter block is usually used for this. It is used to generate a slope after (not before) the falling or rising edge. But if you could "predict the starting point of the red line", I think you could move the edge to that point and use the Rate Limiter block outside of the MATLAB Function block to do the job.
  2 件のコメント
Lucky
Lucky 2020 年 8 月 21 日
Thanks Fangjun for your help. But this still doesnot solve my problem. I do get a slope with this but starts too late and it is too little. Is there a way I can write some statements with counter or for loop in the matlab code to create this slope.
Fangjun Jiang
Fangjun Jiang 2020 年 8 月 21 日
"but starts too late and it is too little"
You said you could "predict the starting point of the red line". That should be the timing for the new falling edge. The rate of the slope can be adjusted by the parameter of the Rate Limiter block.
The MATLAB Function block is executed at every simulation step. You certainly can put in whatever code in the MATLAB Functon block to generate your desired output.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModeling についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by