getFrequencyVector
Vector of frequencies at which estimation is done
Description
Examples
Power Spectrum of Multichannel Sinusoidal Signal
Compute the power spectrum of a multichannel sinusoidal signal using the dsp.SpectrumEstimator
System object™. You can get the vector of frequencies at which the spectrum is estimated using the getFrequencyVector
function. To compute the resolution bandwidth of the estimate (RBW), use the getRBW
function.
Generate a three-channel sinusoid sampled at 1 kHz. Specify sinusoidal frequencies of 100, 200, and 300 Hz. The second and third channels have their phases offset from the first by and , respectively.
sineSignal = dsp.SineWave(SamplesPerFrame=1000,SampleRate=1000, ...
Frequency=[100 200 300],PhaseOffset=[0 pi/2 pi/4]);
Estimate and plot the one-sided spectrum of the signal. Use the dsp.SpectrumEstimator
object for the computation and the dsp.ArrayPlot
for the plotting.
estimator = dsp.SpectrumEstimator(FrequencyRange='onesided'); plotter = dsp.ArrayPlot(PlotType='Line',YLimits=[0 0.75], ... YLabel='Power Spectrum (watts)',XLabel='Frequency (Hz)');
Step through to obtain the data streams and display the spectra of the three channels.
y = sineSignal(); pxx = estimator(y); plotter(pxx)
Get the vector of frequencies at which the spectrum is estimated in Hz, using the getFrequencyVector
function.
f = getFrequencyVector(estimator);
Compute the resolution bandwidth (RBW) of the estimate using the getRBW
function.
getRBW(estimator)
ans = 0.0015
The resolution bandwidth of the signal power spectrum is 0.0015 Hz. This frequency is the smallest frequency that can be resolved on the spectrum.
Input Arguments
estimator
— Estimator object
dsp.SpectrumEstimator
| dsp.CrossSpectrumEstimator
| dsp.TransferFunctionEstimator
Estimator object, specified as one of the following:
dsp.SpectrumEstimator
–– Estimates the power spectrum of the input signal.dsp.CrossSpectrumEstimator
–– Estimates the cross-power spectrum of the input signal.dsp.TransferFunctionEstimator
–– Estimates the transfer function of the system.
Fs
— Input sample rate
positive scalar
Input sample rate, specified as a real positive scalar.
Output Arguments
freq
— Spectrum frequencies
vector
Spectrum frequencies, returned as a column vector.
The length of the frequency vector is determined by
the FrequencyRange
and the FFT length.
If you set the FrequencyRange
to 'onesided'
and the FFT length, NFFT
, is even,
the frequency vector is of length NFFT/2+1
, and covers the interval
[0,SampleRate/2]
.
If you set the FrequencyRange
to 'onesided'
and NFFT
is odd, the frequency
vector is of length (NFFT+1)/2
and covers the interval
[0,SampleRate/2]
.
If you set the FrequencyRange
to 'twosided'
, the frequency vector is of length
NFFT
and covers the interval [0, SampleRate]
.
If you set the FrequencyRange
to 'centered'
, the frequency vector is of length
NFFT
and covers the range [-SampleRate/2,
SampleRate/2]
and [-SampleRate/2, SampleRate/2]
for even
and odd length NFFT
, respectively.
Data Types: single
| double
Version History
Introduced in R2013b
See Also
Functions
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)