Clear Filters
Clear Filters

Over time reduce an input value linearly with a delay after each decrement, using a Simulink model

19 views (last 30 days)
I'm trying to create a Simulink model that has an input value that I want to reduce down to zero in a specific time. It must decrease in linear decrements with a delay after each decrement. The initial input value can also be different, but must reduce down to zero in the same time no matter the starting value.
I have tried using a feedback loop to subtract the original value * the time step, but this just results in the output value decreasing to zero immediately.
Are there any specific blocks for this kind fo linear reduction, or is a more complex block system required?
Thanks for the help

Answers (1)

Govind KM
Govind KM on 13 Sep 2024 at 11:35
Edited: Govind KM on 13 Sep 2024 at 11:42
Hi Steve,
This can be achieved using the “Signal Editor” block, which can create and edit input signals from user specifications manually or through MATLAB expressions. Steps for the same are provided below:
  • Create a “Signal Editor” block in Simulink.
  • Double click on the block and select “Open Signal Editor”.
  • In the “Input” pane, under the default Scenario, double click the existing signal to edit it.
  • Signal elements can be manually added as rows in the tabular area on the right. To specify signals through a MATLAB expression, click on “Author and Replace Signal Data” just under the “Signal” pane.
  • For example, to create a signal which starts from 9 and decreases by 1.5 every second:
repelem(9:-1.5:0,2);
This includes a delay of 1 second after each decrement.
Created signal:
  • Once the required signals and scenarios have been added, use the “Save” button to save the changes to a MAT-file.
  • In the “Signal Editor” block parameters, provide the created MAT-file in the “File Name” parameter and select the created signal under “Active signal”. Now the block will output the created signal to be passed forward in the model.
Details on the “repelem” function and the “Signal Editor” can be found in the following documentations:
Hope it helps!

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!