Borrar filtros
Borrar filtros

Power spectrum of a simple sine wave using simulink

19 visualizaciones (últimos 30 días)
Doyeon Kim
Doyeon Kim el 12 de Abr. de 2022
Respondida: Sudarsanan A K el 10 de Oct. de 2023
I am using 2022a version of Simulink.
I am trying to get a power spectrum of a simple sine wave. The signal generator in the picture generates "sin(2*pi*t)", so I put both amplitude and frequency to be 1. It is required to put a sampling rate of 10Hz and simulation time to 10 seconds, so I put 0.1Hz for zero-order hold, and 10 seconds for stop time.
Before I get them run, I put these values for the Spectrum Analyzer:
I think this should be the same as the picture below and generate the power spectrum, but mine keeps display a straight line.
Could you please give an advice for me to get the same power spectrum?
Thanks in advance.

Respuestas (1)

Sudarsanan A K
Sudarsanan A K el 10 de Oct. de 2023
Hello Doyeon,
I understand that you are trying to visualize the power spectrum of a sine wave using the 'Spectrum Analyzer' block in Simulink. I also note that you have used the 'Signal Generator' block for generating your sine wave and used a 'Zero-Order Hold' block for discretizing the continous signal. Your chosen signal is a pure sinusoid with unit amplitude and frequency, and zero phase. You desire to set a sampling rate of 10 Hz and perform the simulation for 10 seconds. Besides, asper my understanding, you are seeing a flat line on the 'Spectrum Analyzer' instead of the expected impulses at frequencies -1 and 1 as given in the figure attached with the question.
In this case, one possible way to achieve the desired result is by using the 'Sine Wave' block from 'DSP System Toolbox/Sources'. I would allow you to directly set the required format for the time-domain signal. This ensures that the input is correctly interpreted as a time-domain signal with a specific number of samples, allowing the 'Spectrum Analyzer' block to perform spectral analysis and display the frequency content of the input signal accurately.
I have attached below the snapshots showing the model set up and corresponding block properties for your reference:
Note that the 'signal frequency' and 'sample time' is set as per your requirement (1 Hz and 0.1 seconds respectively). The 'Samples per frame' is the number of consecutive samples from each sinusoid to buffer into the output frame, specified as a positive scalar integer.
Further, the block parameter settings for the 'Spectrum Analyzer' is given below.
For a better understanding of the 'Spectrum Analyzer' block in Simulink, you can additionally refer to the following MathWorks Documentation link:
I hope this helps you resolve the issue and gain better understanding of the 'Spectrum Analyzer' block in Simulink.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by