Spectrograms are a two-dimensional representation of the power spectrum of a signal as this signal sweeps through time. They give a visual understanding of the frequency content of your signal. Each line of the spectrogram is one periodogram computed using either the filter bank approach or the Welch’s algorithm of averaging modified periodogram.
To show the concepts of the spectrogram, this example uses the model ex_psd_sa
as the starting point.
Open the model and double-click the Spectrum Analyzer block. In the Spectrum Settings pane, change View to Spectrogram
. The Method is set to Filter bank
. Run the model. You can see the spectrogram output in the spectrum analyzer window. To acquire and store the data for further processing, create a SpectrumAnalyzerConfiguration
object and run the getSpectrumData
function on this object.
Power spectrum is computed as a function of frequency f
and is plotted as a horizontal line. Each point on this line is given a specific color based on the value of the power at that particular frequency. The color is chosen based on the colormap seen at the top of the display. To change the colormap, click View > Configuration Properties, and choose one of the options in color map. Make sure View is set to Spectrogram
. By default, color map is set to jet(256)
.
The two frequencies of the sine wave are distinctly visible at 5 kHz and 10 kHz. Since the spectrum analyzer uses the filter bank approach, there is no spectral leakage at the peaks. The sine wave is embedded in Gaussian noise, which has a variance of 0.0001. This value corresponds to a power of -40 dBm. The color that maps to -40 dBm is assigned to the noise spectrum. The power of the sine wave is 26.9 dBm at 5 kHz and 10 kHz. The color used in the display at these two frequencies corresponds to 26.9 dBm on the colormap. For more information on how the power is computed in dBm, see 'Conversion of power in watts to dBW and dBm'.
To confirm the dBm values, change View to Spectrum
. This view shows the power of the signal at various frequencies.
You can see that the two peaks in the power display have an amplitude of about 26 dBm and the white noise is averaging around -40 dBm.
In the spectrogram display, time scrolls from top to bottom, so the most recent data is shown at the top of the display. As the simulation time increases, the offset time also increases to keep the vertical axis limits constant while accounting for the incoming data. The Offset
value, along with the simulation time, is displayed at the bottom-right corner of the spectrogram scope.
Resolution Bandwidth (RBW) is the minimum frequency bandwidth that can be resolved by the spectrum analyzer. By default, RBW (Hz) is set to Auto
. In the auto mode, RBW is the ratio of the frequency span to 1024. In a two-sided spectrum, this value is Fs/1024, while in a one-sided spectrum, it is (Fs/2)/1024. In this example, RBW is (44100/2)/1024 or 21.53 Hz.
If the Method is set to Filter bank
, using this value of RBW, the number of input samples used to compute one spectral update is given by Nsamples = Fs/RBW, which is 44100/21.53 or 2048 in this example.
If the Method is set to Welch
, using this value of RBW, the window length (Nsamples) is computed iteratively using this relationship:
Nsamples=(1−Op100)×NENBW×FsRBW
Op is the amount of overlap between the previous and current buffered data segments. NENBW is the equivalent noise bandwidth of the window.
For more information on the details of the spectral estimation algorithm, see Spectral Analysis.
To distinguish between two frequencies in the display, the distance between the two frequencies must be at least RBW. In this example, the distance between the two peaks is 5000 Hz, which is greater than RBW. Hence, you can see the peaks distinctly.
Change the frequency of the second sine wave from 10000 Hz to 5015 Hz. The difference between the two frequencies is 15 Hz, which is less than RBW.
On zooming, you can see that the peaks at 5000 Hz and 5015 Hz are not distinguishable.
To increase the frequency resolution, decrease RBW to 1 Hz and run the simulation. On zooming, the two peaks, which are 15 Hz apart, are now distinguishable
Time resolution is the distance between two spectral lines in the vertical axis. By default, Time res (s) is set to Auto
. In this mode, the value of time resolution is 1/RBW
s, which is the minimum attainable resolution. When you increase the frequency resolution, the time resolution decreases. To maintain a good balance between the frequency resolution and time resolution, change the RBW (Hz) to Auto
. You can also specify the Time res (s) as a numeric value.
The spectrum analyzer provides three units to specify the power spectral density: Watts/Hz
, dBm/Hz
, and dBW/Hz
. Corresponding units of power are Watts
, dBm
, and dBW
. For electrical engineering applications, you can also view the RMS of your signal in Vrms
or dBV
. The default spectrum type is Power in dBm
.
Power in dBW
is given by:
PdBW=10log10(power in watt/1 watt)
Power in dBm
is given by:
PdBm=10log10(power in watt/1 milliwatt)
For a sine wave signal with an amplitude of 1 V, the power of a one-sided spectrum in Watts
is given by:
PWatts=A2/2PWatts=1/2
In this example, this power equals 0.5 W. Corresponding power in dBm is given by:
PdBm=10log10(power in watt/1 milliwatt)PdBm=10log10(0.5/10−3)
Here, the power equals 26.9897 dBm. To confirm this value with a peak finder, click Tools > Measurements > Peak Finder.
For a white noise signal, the spectrum is flat for all frequencies. The spectrum analyzer in this example shows a one-sided spectrum in the range [0 Fs/2]. For a white noise signal with a variance of 1e-4, the power per unit bandwidth (Punitbandwidth) is 1e-4. The total power of white noise in watts over the entire frequency range is given by:
Pwhitenoise=Punitbandwidth∗number of frequency bins,Pwhitenoise=(10−4)∗(Fs/2RBW),Pwhitenoise=(10−4)∗(2205021.53)
The number of frequency bins is the ratio of total bandwidth to RBW. For a one-sided spectrum, the total bandwidth is half the sampling rate. RBW in this example is 21.53 Hz. With these values, the total power of white noise in watts is 0.1024 W. In dBm, the power of white noise can be calculated using 10*log10(0.1024/10^-3), which equals 20.103 dBm.
If you set the spectral units to dBFS
and set the full scale (FullScaleSource
) to Auto
, power in dBFS
is computed as:
PdBFS=20⋅log10(√Pwatts/Full_Scale)
where:
Pwatts
is the power in watts
For double and float signals, Full_Scale is the maximum value of the input signal.
For fixed point or integer signals, Full_Scale is the maximum value that can be represented.
If you specify a manual full scale (set FullScaleSource
to Property
), power in dBFS
is given by:
PFS=20⋅log10(√Pwatts/FS)
Where FS
is the full scaling factor specified in the FullScale
property.
For a sine wave signal with an amplitude of 1 V, the power of a one-sided spectrum in Watts
is given by:
PWatts=A2/2PWatts=1/2
In this example, this power equals 0.5 W and the maximum input signal for a sine wave is 1 V. The corresponding power in dBFS is given by:
PFS=20⋅log10(√1/2/1)
Here, the power equals -3.0103. To confirm this value in the spectrum analyzer, run these commands:
Fs = 1000; % Sampling frequency sinef = dsp.SineWave('SampleRate',Fs,'SamplesPerFrame',100); scope = dsp.SpectrumAnalyzer('SampleRate',Fs,... 'SpectrumUnits','dBFS','PlotAsTwoSidedSpectrum',false) %% for ii = 1:100000 xsine = sinef(); scope(xsine) end
Then, click Tools > Measurements > Peak Finder.
Power in dBm
is given by:
PdBm=10log10(power in watt/1 milliwatt)
Voltage in RMS is given by:
Vrms=10PdBm/20√10−3
From the previous example, PdBm equals 26.9897 dBm. The Vrms is calculated as
Vrms=1026.9897/20√0.001
which equals 0.7071.
To confirm this value:
Change Type to RMS
.
Open the peak finder by clicking Tools > Measurements > Peak Finder.
When you run the model and do not see the spectrogram colors, click the Scale Color Limits button. This option autoscales the colors.
The spectrogram updates in real time. During simulation, if you change any of the tunable parameters in the model, the changes are effective immediately in the spectrogram.
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.
Desktop Basics - MATLAB & Simulink
Array Indexing - MATLAB & Simulink
Workspace Variables - MATLAB & Simulink
Text and Characters - MATLAB & Simulink
Calling Functions - MATLAB & Simulink
2-D and 3-D Plots - MATLAB & Simulink
Programming and Scripts - MATLAB & Simulink
Help and Documentation - MATLAB & Simulink
Creating, Concatenating, and Expanding Matrices - MATLAB & Simulink
Removing Rows or Columns from a Matrix
Reshaping and Rearranging Arrays
Add Title and Axis Labels to Chart
Change Color Scheme Using a Colormap
How Surface Plot Data Relates to a Colormap
How Image Data Relates to a Colormap
Time-Domain Response Data and Plots
Time-Domain Responses of Discrete-Time Model
Time-Domain Responses of MIMO Model
Time-Domain Responses of Multiple Models
Introduction: PID Controller Design
Introduction: Root Locus Controller Design
Introduction: Frequency Domain Methods for Controller Design
DC Motor Speed: PID Controller Design
DC Motor Position: PID Controller Design
Cruise Control: PID Controller Design
Suspension: Root Locus Controller Design
Aircraft Pitch: Root Locus Controller Design
Inverted Pendulum: Root Locus Controller Design
Get Started with Deep Network Designer
Create Simple Image Classification Network Using Deep Network Designer
Build Networks with Deep Network Designer
Classify Image Using GoogLeNet
Classify Webcam Images Using Deep Learning
Transfer Learning with Deep Network Designer
Train Deep Learning Network to Classify New Images
Deep Learning Processor Customization and IP Generation
Prototype Deep Learning Networks on FPGA
Deep Learning Processor Architecture
Deep Learning INT8 Quantization
Quantization of Deep Neural Networks
Custom Processor Configuration Workflow
Estimate Performance of Deep Learning Network by Using Custom Processor Configuration
Preprocess Images for Deep Learning
Preprocess Volumes for Deep Learning
Transfer Learning Using AlexNet
Time Series Forecasting Using Deep Learning
Create Simple Sequence Classification Network Using Deep Network Designer
Train Classification Models in Classification Learner App
Train Regression Models in Regression Learner App
Explore the Random Number Generation UI
Logistic regression create generalized linear regression model - MATLAB fitglm 2
Support Vector Machines for Binary Classification
Support Vector Machines for Binary Classification 2
Support Vector Machines for Binary Classification 3
Support Vector Machines for Binary Classification 4
Support Vector Machines for Binary Classification 5
Assess Neural Network Classifier Performance
Discriminant Analysis Classification
Train Generalized Additive Model for Binary Classification
Train Generalized Additive Model for Binary Classification 2
Classification Using Nearest Neighbors
Classification Using Nearest Neighbors 2
Classification Using Nearest Neighbors 3
Classification Using Nearest Neighbors 4
Classification Using Nearest Neighbors 5
Gaussian Process Regression Models
Gaussian Process Regression Models 2
Understanding Support Vector Machine Regression
Extract Voices from Music Signal
Align Signals with Different Start Times
Find a Signal in a Measurement
Extract Features of a Clock Signal
Filtering Data With Signal Processing Toolbox Software
Find Periodicity Using Frequency Analysis
Find and Track Ridges Using Reassigned Spectrogram
Classify ECG Signals Using Long Short-Term Memory Networks
Waveform Segmentation Using Deep Learning
Label Signal Attributes, Regions of Interest, and Points
Introduction to Streaming Signal Processing in MATLAB
Filter Frames of a Noisy Sine Wave Signal in MATLAB
Filter Frames of a Noisy Sine Wave Signal in Simulink
Lowpass Filter Design in MATLAB
Tunable Lowpass Filtering of Noisy Input in Simulink
Signal Processing Acceleration Through Code Generation
Signal Visualization and Measurements in MATLAB
Estimate the Power Spectrum in MATLAB
Design of Decimators and Interpolators
Multirate Filtering in MATLAB and Simulink