Generate staircase waveform from given sine waveform in Simulink

9 visualizaciones (últimos 30 días)
Tharun
Tharun el 30 de Abr. de 2024
Respondida: Poorna el 3 de Mayo de 2024
Hi,
I want to generate a staircase waveform from the following waveform
Vin = 0.5(1+sin(wt));// wt = 2*pi*50;
with following procedure:
1) Mark the blocks of fixed duration (eg: 2.5 msec) for the entire waveform.
2) Average the waveform within each block and output the waveform with each horizontal line in a block indicating the average value of the waveform.

Respuestas (2)

Animesh
Animesh el 3 de Mayo de 2024
Hey @Tharun
Consider the use of a Quantizer block in Simulink for this scenario. The Quantizer block discretizes the input signal by mapping the signal value to quantized value (here, the average of the waveform in the Quantization interval).
Passing a Sine Wave through the Quantizer block will convert it into a “Staircase waveform.”
The model would look something like this:
You can adjust the block parameters of the Sine Wave block to set properties such Amplitude, Frequency, Bias, and Phase of the sine wave.
Similarly, you can set Quantization interval in Quantizer block to set the interval after which you must take the waveform average.
You can refer to the following MathWorks documentations for more information:

Poorna
Poorna el 3 de Mayo de 2024
Hi Tharun,
I believe you are aware of plotting the first graph using basic simulink blocks. To generate the second graph from the first graph, you could use the "Buffer" block and the "Moving average" block.
1) Once you generate the sine wave from the first graph. Make sure to set the sample time of all the source blocks to some discrete time. Pass this generated signal to a "Buffer" block.( The input to a "Buffer" block must be a discrete-time signal )
2) Set the buffer size to the number of samples you want to average. For example, if the time period of the sine signal is 1 sec and if you want to divide the signal into 8 blocks then each signal block is of 125ms. If the sample time of the input signal is 0.001, then it means we get 1000 samples for 1 timeperiod of the sine wave. To get 8 averages you would need to set the buffer size to 125.
3) Now pass the output of this "Buffer" block to the input of the "Moving average" block. Set the "window length" property to the buffer size( 125 in case of the above example ). Set the the "overlap length" to 0.
4) Connect the output to the scope to visualize the desired signal.
Note that the output wil be delayed by amount of samples you are computing the average for. This is because the average of the first 125 samples from the above case will be computed only after receiving the first 125 samples.
To know more about the blocks mentioned above, refer to the following documentation:
Hope this Helps!

Community Treasure Hunt

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

Start Hunting!

Translated by