Good day,
I've got a repeating sequence block with a 1x2-matrix for the durations of the output values. I however need to change these values, each entry, according to a ramp function that implements a linear increase. Below is a setup of the model I currently have in Simulink.
Any idea on how I can achieve this?

 Risposta accettata

Jon
Jon il 26 Ott 2021
Modificato: Jon il 26 Ott 2021

0 voti

Under source blocks in the Simulink library there is a block called Ramp. It seems like this should work for your purpose.

6 Commenti

Hi John,
I'm familiar with the ramp block and have implemented it elsewhere in the model. The real trick is to get the "Ramp" block to work/feed into the "Repeating Sequence" block.
If you have any help regarding that matter it would be greatly appreciated.
Thanks
Jon
Jon il 26 Ott 2021
Modificato: Jon il 26 Ott 2021
I'm still not completely clear on what signal you are trying to generate but I'm now thinking it is a sequence of ramps with linearly increasing amplitude. Is this closer to what you are looking for? I construct the signal as a product of a repeating sequence and an increasing stair case.
Also, you could alway construct some arbitrary waveform in MATLAB and then feed it in using the from workspace block.
Hi John,
So the "Repeating Sequence" block in my case outputs a square waveform with a constant frequency/period. I need to increase the frequency (or decrease the period) as the simulation progresses.
The waveform I'm after looks like this:
Jon
Jon il 27 Ott 2021
I think you could get what you are looking for using a chirp (sine wave with linearly varying frequency followed by a sign block to turn it into a square wave. Note that the chirp frequency can either increase or decrease. You set the initial and final frequencies. Also if you need to phase shift it you could insert a delay.
Jon
Jon il 27 Ott 2021
Modificato: Jon il 27 Ott 2021
I now see you want the square wave to go from say 0 to 5 rather than -1 to 1. You can just add 1 to the output of the sign block (using a sum block and constant) and then scale it with a gain block.
If you need the on and off (low and high values) duration to be different, you can offset the chirp signal (add a constant) before you apply the sign function.
Hi John,
So I actually managed to figure it out on my own using the blocks shown below:
So what happens is:
  • Using a "Variable Pulse Generator" block to generate pulses with the frequency specified by the preceeding blocks.
  • I then simply add the appropriate gain (5).
  • Finally, each signal is delayed by a time stamp according to my requirement with the "Transport Delay" block.
But thanks once more for your time and effort to help me get to the bottom of this!
Christo

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by