main content

(to be removed) display frequency spectrum of time-凯发k8网页登录

(to be removed) display frequency spectrum of time-domain signals

  • the dsp.spectrumanalyzer object will be removed in a future release. use the spectrumanalyzer matlab® object instead.

  • the ccdfmeasurements property of the dsp.spectrumanalyzer object will be removed in a future release. use the powermeter object instead to compute and visualize ccdf measurements.

for more information on how to replace your existing code, see compatibility considerations.

description

the spectrum analyzer system object™ displays the frequency spectrum of time-domain signals. this scope supports variable-size input, which allows the input frame size to change. frame size is the first dimension of the input vector. the number of input channels must remain constant.

to display the spectra of signals in the spectrum analyzer:

  1. create the dsp.spectrumanalyzer object and set its properties.

  2. call the object with arguments, as if it were a function.

to learn more about how system objects work, see what are system objects?

creation

description

scope = dsp.spectrumanalyzer creates a spectrum analyzer system object. this object displays the frequency spectrum of real- and complex-valued floating- and fixed-point signals.

scope = dsp.spectrumanalyzer(ports) creates a spectrum analyzer object and sets the numinputports property to the value of ports.

scope = dsp.spectrumanalyzer(name,value) sets properties using one or more name-value pairs. enclose each property name in single quotes.

properties

unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. objects lock when you call them, and the function unlocks them.

if a property is tunable, you can change its value at any time.

for more information on changing property values, see .

frequently used

number of input ports, specified as a positive integer. each signal coming through a separate input becomes a separate channel in the scope. you must invoke the scope with the same number of inputs as the value of this property.

the domain of the input signal you want to visualize, specified as "time" or "frequency". if you visualize time-domain signals, the spectrum analyzer transforms the signal to the frequency spectrum based on the algorithm specified in the method property.

scope window use

in the estimation tab on the spectrum analyzer toolstrip, set input domain to time or frequency.

data types: char | string

spectrum type, specified as one of these:

"power" — power spectrum

"power density" — power spectral density. the power spectral density is the magnitude squared of the spectrum normalized to a bandwidth of 1 hz.

"rms" — root mean square. the root mean square shows the square root of the mean square. use this option to view the frequency of voltage or current signals.

tunable: yes

dependency

to enable this property, set inputdomain to "time".

scope window use

in the analyzer tab on the spectrum analyzer toolstrip, select spectrum. click spectrum to select power, power density, or rms.

to enable these options, set the input domain on the estimation tab to time.

data types: char | string

specify the spectrum type as one of "spectrum", "spectrogram", or "spectrum and spectrogram".

  • "spectrum" — shows the power spectrum.

  • "spectrogram" — shows frequency content over time. each line of the spectrogram is one periodogram. time scrolls from the bottom to the top of the display. the most recent spectrogram update is at the bottom of the display.

  • "spectrum and spectrogram" — shows a dual view of a spectrum and spectrogram.

tunable: yes

scope window use

in the analyzer tab on the spectrum analyzer toolstrip, select spectrum, spectrogram, or both.

data types: char | string

specify the sample rate, in hertz, of the input signals as a finite numeric scalar.

scope window use

open the spectrum settings. in the main options section, set sample rate (hz).

spectrum estimation method, specified as one of the following:

  • "filter bank" –– use an analysis filter bank to estimate the power spectrum. compared to welch's method, this method has a lower noise floor, better frequency resolution, and lower spectral leakage and requires fewer samples per update.

  • "welch" –– use welch's method of averaged modified periodograms.

for more details on these methods, see .

tunable: yes

dependency

to enable this property, set inputdomain to "time".

scope window use

in the estimation tab of the spectrum analyzer toolstrip, set method to filter bank or welch.

to enable this parameter, set input domain to time in the estimation tab.

data types: char | string

option to plot a two-sided spectrum, specified as one of the following:

  • true — compute and plot two-sided spectral estimates. when the input signal is complex valued, you must set this property to true.

  • false — compute and plot one-sided spectral estimates. if you set this property to false, then the input signal must be real valued.

    when you set this property to false, the spectrum analyzer uses power-folding. the y-axis values are twice the amplitude that they would be if you were to set this property to true, except at 0 and the nyquist frequency. a one-sided power spectral density (psd) contains the total power of the signal in the frequency interval from dc to half the nyquist rate. for more information, see .

tunable: yes

scope window use

click the spectrum tab or the spectrogram tab (if enabled) of the spectrum analyzer toolstrip. in the trace options section, select two-sided spectrum to compute and plot two-sided spectral estimates.

data types: logical

scale to display frequency, specified as one of the following:

  • "linear" — use a linear scale to display frequencies on the x-axis. to use the "linear" setting, you must also set the plotastwosidedspectrum property to true.

  • "log" — use a logarithmic scale to display frequencies on the x-axis. to use the "log" setting, you must also set the plotastwosidedspectrum property to false.

tunable: yes

scope window use

click the spectrum tab or the spectrogram tab (if enabled) of the spectrum analyzer toolstrip. in the scale section, set the frequency scale to linear or log.

to set the frequency scale to log, clear the two-sided spectrum check box in the trace options section in the spectrum or the spectrogram tab (if enabled). if you select the two-sided spectrum check box, then you must set the frequency scale to linear.

data types: char | string

advanced

frequency span mode, specified as one of the following:

  • "full" –– the spectrum analyzer computes and plots the spectrum over the entire nyquist frequency interval.

  • "span and center frequency" –– the spectrum analyzer computes and plots the spectrum over the interval specified by the span and centerfrequency properties.

  • "start and stop frequencies" –– the spectrum analyzer computes and plots the spectrum over the interval specified by the startfrequency and stopfrequency properties.

tunable: yes

dependency

to enable this property, set inputdomain to "time".

scope window use

click the estimation tab on the spectrum analyzer toolstrip. in the frequency options section, set frequency span to full, span and center frequency, or start and stop frequencies.

to enable the frequency span, set input domain to time.

data types: char | string

specify the frequency span, in hertz, over which the spectrum analyzer computes and plots the spectrum. the overall span, defined by this property and the centerfrequency property, must fall within the nyquist frequency interval.

tunable: yes

dependency

to enable this property, set frequencyspan to "span and center frequency".

scope window use

open the spectrum settings. in the main options section, clear the full frequency span check box and set span.

start of the frequency interval over which spectrum is computed, specified in hertz as a real scalar. the overall span, which is defined by this property and stopfrequency, must fall within the nyquist frequency interval.

tunable: yes

dependency

to enable this property, set frequencyspan to "start and stop frequencies".

scope window use

open the spectrum settings. in the main options section, clear the full frequency span and change span to fstart. set fstart (hz).

end of the frequency interval over which spectrum is computed, specified in hertz as a real scalar. the overall span, which is defined by this property and the startfrequency property, must fall within the nyquist frequency interval.

tunable: yes

dependency

to enable this property, set frequencyspan to "start and stop frequencies".

scope window use

open the spectrum settings. in the main options section, clear the full frequency span and change span to fstart. set fstop (hz).

specify in hertz the center frequency of the span over which the spectrum analyzer computes and plots the spectrum. the overall frequency span, defined by the span and this property, must fall within the nyquist frequency interval.

tunable: yes

dependency

to enable this property, set frequencyspan to "span and center frequency".

scope window use

open the spectrum settings. in the main, clear full frequency span and set cf (hz).

specify the frequency resolution method of the spectrum analyzer.

  • "rbw" - the rbwsource and rbw properties control the frequency resolution (in hz) of the analyzer. the fft length is the window length that results from achieving the specified rbw value or 1024, whichever is larger.

  • "windowlength" - applies only when the method property is set to "welch". the windowlength property controls the frequency resolution. you can control the number of fft points only when the frequencyresolutionmethod property is "windowlength".

  • "numfrequencybands" - applies only when the method property is set to "filter bank". the fftlengthsource and fftlength properties control the frequency resolution.

tunable: yes

dependency

to enable this property, set inputdomain to "time".

scope window use

open the spectrum settings. in the main options section, set the frequency resolution method by selecting the rbw (hz) dropdown.

data types: char | string

specify the source of the resolution bandwidth (rbw) as either "auto" or "property".

  • "auto" — the spectrum analyzer adjusts the spectral estimation resolution to ensure that there are 1024 rbw intervals over the defined frequency span.

  • "property" — specify the resolution bandwidth directly using the rbw property.

tunable: yes

dependency

to enable this property, set either:

  • inputdomain to "time" and frequencyresolutionmethod to "rbw".

  • inputdomain to "frequency".

scope window use

open the spectrum settings. in the main options section, set rbw (hz).

data types: char | string

rbw controls the spectral resolution of spectrum analyzer. specify the resolution bandwidth in hertz as a real positive scalar. you must specify a value to ensure that there are at least two rbw intervals over the specified frequency span. thus, the ratio of the overall span to rbw must be greater than two:

spanrbw>2

you can specify the overall span in different ways based on how you set the frequencyspan property.

dependency

to enable, set:

  • rbwsource to "property"

scope window use

open the spectrum settings. in the main options section, set rbw (hz).

control the frequency resolution by specifying the window length, in samples used to compute the spectral estimates. the window length must be an integer scalar greater than 2.

tunable: yes

dependencies

to enable this property, set:

  • frequencyresolutionmethod to "windowlength", which controls the frequency resolution based on your window length setting

  • method to "welch"

scope window use

open the spectrum settings. change the rbw (hz) dropdown to window length.

  • "auto" - sets the fft length to the window length specified in the windowlength property or 1024, whichever is larger.

  • "property" - number of fft points using the fftlength property. fftlength must be greater than windowlength.

tunable: yes

dependency

to enable this property, set frequencyresolutionmethod to "windowlength".

scope window use

open the spectrum settings. in the main options section, next to the rbw (hz) option, enter a number or select auto.

data types: char | string

specify the length of the fft that the spectrum analyzer uses to compute spectral estimates.

if frequencyresolutionmethod is "rbw", the fft length is set as the window length required to achieve the specified resolution bandwidth value or 1024, whichever is larger.

tunable: yes

dependencies

to use this property, the following must be true:

  • frequencyresolutionmethod is set to "windowlength" or "numfrequencybands"

  • fftlength is greater than or equal to the windowlength.

  • fftlengthsource is set to "property".

scope window use

open the spectrum settings. in the main options section, next to the rbw (hz) option, enter a number or select auto.

specify the number of filter taps or coefficients for each frequency band. this number must be a positive even integer. this value corresponds to the number of filter coefficients per polyphase branch. the total number of filter coefficients is equal to numtapsperband fftlength.

dependency

to enable this property, set method to "filter bank"

scope window use

open the spectrum settings. in the main options section, set taps per band.

  • "auto" — the frequency vector is calculated from the length of the input. see frequency vector.

  • "property" — enter a custom vector as the frequency vector.

dependency

to enable this property, set inputdomain to "frequency".

scope window use

open the spectrum settings. in the frequency input options section, set frequency (hz).

data types: char | string

custom frequency vector, specified as a monotonically increasing vector. this vector determines the x-axis of the display. the vector must be monotonically increasing and must have the same length as the input signal frame size.

tunable: yes

dependency

to enable this property, set:

  • inputdomain to "frequency".

  • frequencyvectorsource to "property".

to .

scope window use

click the estimation tab on the spectrum analyzer toolstrip. in the domain section, set frequency (hz) to a monotonically increasing vector of length equal to the input signal frame size.

to enable the frequency (hz), set input domain to frequency.

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

the percentage overlap between the previous and current buffered data segments, specified as a real, scalar value. the overlap creates a window segment that is used to compute a spectral estimate. the value must be greater than or equal to zero and less than 100.

tunable: yes

scope window use

open the spectrum settings. in the window options section, set overlap (%).

specify a window function for the spectral estimator. the following table shows preset windows. for more information, follow the link to the corresponding function reference in the signal processing toolbox™ documentation.

window optioncorresponding signal processing toolbox function
"rectangular"
"chebyshev"
"flat top"
"hamming"
"hann"
"kaiser"
"blackman-harris"

to set your own spectral estimation window, set this property to "custom" and specify a custom window function in the customwindow property.

tunable: yes

dependency

to enable this property, set:

  • inputdomain to "time".

  • method to "welch"

scope window use

click the estimation tab on the spectrum analyzer toolstrip. in the window options section, set the window.

to enable the window, set input domain to time and method to welch in the estimation tab on the spectrum analyzer toolstrip.

data types: char | string

name of the custom window function, specified as a character vector or string scalar. the name of the custom window function must be on the matlab path. use this property if you want to customize the window using additional properties available with the signal processing toolbox version of the window function.

tunable: yes

example

define and use a custom window function.

function w = my_hann(l)
    w = hann(l, 'periodic')
end
scope.window = 'custom';
scope.customwindow = 'my_hann'

dependency

to use this property, set window to "custom".

scope window use

click the estimation tab on the spectrum analyzer toolstrip. in the window options section, for the window, enter the name of the custom window function.

data types: char | string

the window sidelobe attenuation, in decibels (db). the value must be greater than or equal to 45.

tunable: yes

dependency

to enable this property, set window to "chebyshev" or "kaiser".

scope window use

open the spectrum settings. in the window options section, set attenuation (db).

select the units of the frequency-domain input. this property allows the spectrum analyzer to scale frequency data if you choose a different display unit with the spectrumunits property.

dependency

this option is only available when inputdomain is set to frequency.

scope window use

open the spectrum settings. in the frequency input options section, set input units.

data types: char | string

specify the units in which the spectrum analyzer displays power values.

tunable: yes

dependency

the spectrum units available depend on the value you specify in the spectrumtype property.

inputdomainspectrumtypeallowed spectrumunits
"time""power""dbm", "dbw", "dbfs", "watts"
"power density""dbm/hz", "dbw/hz","dbfs/hz", "watts/hz"
"rms""dbv", "vrms"
"frequency""auto", "dbm", "dbv", "dbw", "vrms", "watts"

if you set the inputdomain property to "frequency" and the spectrumunits property to "auto", the spectrum analyzer assumes the spectrum units to be equal to input units specified in the inputunits property. if you set inputdomain to "time" and spectrumunits to any option other than "auto", then the spectrum analyzer converts the units specified in inputunits to the units specified in spectrumunits.

scope window use

click the spectrum tab on the spectrum analyzer toolstrip. in the scale section, set spectrum unit.

data types: char | string

specify the source of the dbfs scaling factor as either "auto" or "property".

  • "auto" –– the spectrum analyzer adjusts the scaling factor based on the input data.

  • "property" –– specify the full-scale scaling factor using the fullscale property.

tunable: yes

dependency

to enable this property, set:

  • inputdomain to "time"

  • spectrumtype to "power" or "power density"

  • spectrumunits to "dbfs" or "dbfs/hz" (when spectrum type is set to "power density")

scope window use

click the spectrum tab on the spectrum analyzer toolstrip. in the scale section, set the full scale to either auto or a positive scalar.

to enable the full scale:

  • in the analyzer tab, set the spectrum type to power or power density.

  • in the estimation tab, set input domain to time.

  • in the spectrum tab, set spectrum unit to dbfs or dbfs/hz (when spectrum type is set to power density).

data types: char | string

specify a real positive scalar for the dbfs full scale.

tunable: yes

dependency

to enable this option set:

  • spectrumunits to "dbfs"

  • fullscalesource to "property"

scope window use

open the spectrum settings. in the trace options section, set full scale to auto or enter a number.

averaging method, specified as one of the following:

  • "vbw" — video bandwidth method. the object uses a lowpass filter to smooth the trace and decrease noise. use the vbwsource and vbw properties to specify the vbw value.

  • "exponential" — weighted average of samples. the object computes the average over samples weighted by an exponentially decaying forgetting factor. use the forgettingfactor property to specify the weighted forgetting factor.

for more information, see .

tunable: yes

dependency

to enable this property, set inputdomain to "time".

scope window use

click the estimation tab on the spectrum analyzer toolstrip. in the averaging section, set averaging method to vbw or exponential.

to enable the averaging method, set input domain to time.

data types: char | string

the spectrum analyzer computes the current power spectrum estimate by computing a running average of the last n power spectrum estimates. this property defines n.

tunable: yes

dependency

to enable this property, set viewtype to "spectrum".

dependency

this property applies only when the averagingmethod is "running".

scope window use

open the spectrum settings. in the trace options section, set averages.

specify the exponential weighting as a scalar value greater than 0 and less than or equal to 1.

dependency

this property applies only when the averagingmethod is "exponential".

scope window use

open the spectrum settings. in the trace options section, set forgetting factor.

the load the scope uses as a reference to compute power levels.

tunable: yes

scope window use

open the spectrum settings. in the trace options section, set ref. load (ohms).

  • scalar — apply the same frequency offset to all channels, specified in hertz as a character vector.

  • vector — apply a specific frequency offset for each channel, specify a vector of frequencies. the vector length must be equal to number of input channels.

    the frequency-axis values are offset by the values specified in this property. the overall span must fall within the nyquist frequency interval. you can control the overall span in different ways based on how you set the frequencyspan property.

tunable: yes

scope window use

open the spectrum settings. in the trace options section, set offset (hz).

spectrogram

specify the channel for which the spectrogram is plotted, as a real, positive scalar integer in the range [1 n], where n is the number of input channels.

tunable: yes

dependency

to enable this property, set viewtype to "spectrogram" or "spectrum and spectrogram".

scope window use

open the spectrum settings. in the spectrogram options section, select a channel.

specify the source for the time resolution of each spectrogram line as either "auto" or "property". the timeresolution property shows the time resolution for the different frequency resolution methods and time resolution properties.

tunable: yes

dependency

to enable this property, set viewtype to "spectrogram" or "spectrum and spectrogram".

scope window use

click the spectrogram tab on the spectrum analyzer toolstrip. in the time options section, set the time resolution (s) to auto or enter a positive scalar.

to enable the time resolution (s), select spectrogram in the analyzer tab.

data types: char | string

specify the time resolution of each spectrogram line as a positive scalar, expressed in seconds.

the spectrum analyzer determines the time resolution value based on the frequency resolution method, rbw, and time resolution properties.

methodrbwtime resolutionresulting time resolution in seconds
welch or filter bankautoauto1/rbw
welch or filter bankautomanually entered1/time resolution hz
welch or filter bankmanually enteredauto1/rbw seconds
welch or filter bankmanually enteredmanually enteredequal to or greater than the minimum attainable time resolution 1/rbw. the spectrum analyzer combines several spectral estimates into one spectrogram line to obtain the desired time resolution. it uses interpolation to obtain time resolution values that are not integer multiples of 1/rbw.

tunable: yes

dependency

to enable this property, set:

  • viewtype to "spectrogram" or "spectrum and spectrogram"

  • timeresolutionsource to "property.

scope window use

open the spectrum settings. in the spectrogram options section, in the time res (s) box, enter a number.

source for the time span of the spectrogram, specified as either "auto" or "property". if you set this property to "auto", the spectrogram displays 100 spectrogram lines at any given time. if you set this property to "property", the spectrogram uses the time duration you specify in seconds in the timespan property.

tunable: yes

dependency

to enable this property, set viewtype to "spectrogram" or "spectrum and spectrogram".

scope window use

click the spectrogram tab on the spectrum analyzer toolstrip. in the time options section, set the time span (s) to auto or enter a positive scalar.

data types: char | string

specify the time span of the spectrogram display in seconds. you must set the time span to be at least twice as large as the duration of the number of samples required for a spectral update.

tunable: yes

dependency

to enable this property, set:

  • viewtype to "spectrogram" or "spectrum and spectrogram".

  • timespansource to "property".

scope window use

open the spectrum settings. in the spectrogram options section, in the time span (s) box, enter a number.

measurements

channel for which the measurements are obtained, specified as a real, positive integer greater than 0 and less than or equal to 100. the maximum number you can specify is the number of channels (columns) in the input signal.

tunable: yes

scope window use

click on tools > measurements and open the trace selection settings.

data types: double

specify whether to display upper and lower spectral mask lines on a spectrum plot. this property uses properties from a object to enable and configure the spectral masks.

tunable: yes

scope window use

open the spectral mask pane and modify the settings options.

peak finder measurement, specified as a object. enable peak finder to compute and display the largest calculated peak values. all peakfinderconfiguration properties are tunable.

tunable: yes

dependency

to enable this property, set viewtype to "spectrum" or "spectrum and spectrogram".

scope window use

click the measurements tab on the spectrum analyzer toolstrip and modify the peak finder measurements in the peaks section.

the measurements tab appears when you select spectrum in the analyzer tab.

cursor measurements, specified as a object. enable cursor measurements to display waveform cursors. all cursormeasurementsconfiguration properties are tunable.

tunable: yes

dependency

to enable this property, set viewtype to "spectrum" or "spectrum and spectrogram".

scope window use

click the measurements tab on the spectrum analyzer toolstrip and modify the cursor measurements in the cursors section.

the measurements tab appears when you select spectrum in the analyzer tab.

enable channel measurements to compute and display the occupied bandwidth or adjacent channel power ratio. the channelmeasurements property uses the channelmeasurementsspecification properties.

the channelmeasurementsspecification properties are:

  • algorithm –– type of measurement data to display, specified as either "occupied bw" or "acpr".

    default: "occupied bw"

  • frequencyspan –– frequency span mode, specified as either "span and center frequency" or "start and stop frequencies"

    default: "span and center frequency"

  • span –– frequency span over which the channel measurements are computed, specified as a real, positive scalar in hz. this property applies when you set the frequencyspan property to "span and center frequency".

    default: 2000 hz

  • centerfrequency –– center frequency of the span over which the channel measurements are computed, specified as a real scalar in hz. this property applies when you set the frequencyspan property to "span and center frequency".

    default: 0 hz

  • startfrequency –– start frequency over which the channel measurements are computed, specified as a real scalar in hz. this property applies when you set the frequencyspan property to "start and stop frequencies".

    default: -1000 hz

  • stopfrequency –– stop frequency over which the channel measurements are computed, specified as a real scalar in hz. this property applies when you set the frequencyspan property to "start and stop frequencies".

    default: 1000 hz

  • percentoccupiedbw –– percent of power over which to compute the occupied bandwidth, specified as a positive real scalar. this property applies when you set the algorithm property to "occupied bw".

    default: 99

  • numoffsets –– number of adjacent channel pairs, specified as a real, positive integer. this property applies when you set the algorithm property to "acpr".

    default: 2

  • adjacentbw –– adjacent channel bandwidth, specified as a real, positive scalar. this property applies when you set the algorithm property to "acpr".

    default: 1000

  • filtershape –– filter shape for both main and adjacent channels, specified as "none", "gaussian", or "rrc". this property applies when you set the algorithm property to "acpr".

    default: "none"

  • filtercoeff –– channel filter coefficient, specified as a real scalar between 0 and 1. this property applies when you set the algorithm property to "acpr" and the filtershape property to either "gaussian" or "rrc".

    default: 0.5

  • acproffsets –– frequency of the adjacent channel relative to the center frequency of the main channel, specified as a real vector of length equal to the number of offset pairs specified in numoffsets. this property applies when you set the algorithm property to "acpr".

    default: [2000 3500]

  • enable –– set this property to true to enable channel measurements. valid values are true or false.

    default: false

all channelmeasurementsspecification properties are tunable.

scope window use

open the channel measurements pane () and modify the measurement and channel settings options.

distortion measurements, specified as a object. enable distortion measurements to compute and display the harmonic distortion and intermodulation distortion. all distortionmeasurementsconfiguration properties are tunable.

tunable: yes

dependency

to enable this property, set viewtype to "spectrum" or "spectrum and spectrogram".

scope window use

click the measurements tab on the spectrum analyzer toolstrip and modify the distortion measurements in the distortion section.

the measurements tab appears when you select spectrum in the analyzer tab.

visualization

caption to display in the scope window, specified as a character vector or string scalar.

tunable: yes

data types: char | string

spectrum analyzer window position in pixels, specified by the size and location of the scope window as a four-element double vector of the form [left bottom width height]. you can place the scope window in a specific position on your screen by modifying the values to this property.

by default, the window appears in the center of your screen with a width of 800 pixels and height of 450 pixels. the exact center coordinates depend on your screen resolution.

tunable: yes

plot type to display normal traces, specified as "line" or "stem". normal traces are traces that display free-running spectral estimates.

tunable: yes

dependencies

to enable this property, set:

  • viewtype to "spectrum" or "spectrum and spectrogram".

  • plotnormaltrace to true.

scope window use

click the analyzer tab on the spectrum analyzer toolstrip, navigate to the configuration section and click settings. in the spectrum analyzer settings window, under display and labels, set plot type to line or stem.

to enable the plot type, you must:

  • select spectrum in the views section of the analyzer tab.

  • enable the normal trace check box in the trace options section of the spectrum tab.

data types: char | string

to remove normal traces from the display, set this property to false. these traces display the free-running spectral estimates. the spectrum analyzer continues its spectral computations even when you set this property to false.

tunable: yes

dependency

to enable this property, set viewtype to "spectrum" or "spectrum and spectrogram".

scope window use

click the spectrum tab on the spectrum analyzer toolstrip and select the normal trace check box in the trace options section.

to enable the normal trace check box, select spectrum in the analyzer tab.

data types: logical

to compute and plot the maximum-hold spectrum of each input channel, set this property to true. the maximum-hold spectrum at each frequency bin is computed by keeping the maximum value of all the power spectrum estimates. when you toggle this property, the spectrum analyzer resets its maximum-hold computations.

tunable: yes

dependency

to enable this property, set viewtype to "spectrum" or "spectrum and spectrogram".

scope window use

click the spectrum tab on the spectrum analyzer toolstrip and select the max-hold trace check box in the trace options section.

to enable the max-hold trace check box, select spectrum in the analyzer tab.

data types: logical

to compute and plot the minimum-hold spectrum of each input channel, set this property to true. the minimum-hold spectrum at each frequency bin is computed by keeping the minimum value of all the power spectrum estimates. when you toggle this property, the spectrum analyzer resets its minimum-hold computations.

tunable: yes

dependency

to enable this property, set viewtype to "spectrum" or "spectrum and spectrogram".

scope window use

click the spectrum tab on the spectrum analyzer toolstrip and select the min-hold trace check box in the trace options section.

to enable the min-hold trace check box, select spectrum in the analyzer tab.

data types: logical

display title, specified as a character vector or a string scalar.

tunable: yes

scope window use

click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that opens up, under display and labels, enter title.

data types: char | string

y-axis label, specified as a character vector or a string scalar. the spectrum analyzer displays the label to the left of the y-axis.

regardless of the value of this property, spectrum analyzer always displays power units as one of the spectrumunits values.

tunable: yes

dependency

to enable this property, set viewtype to "spectrum" or "spectrum and spectrogram".

scope window use

click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that opens up, under display and labels, enter y-label.

to enable the y-label, select spectrum in the analyzer tab.

data types: char | string

flag to show the legend, specified as true or false. to show a legend with the input names, set this property to true.

use the legend to control which signals are visible. in the scope legend, click a signal name to hide the signal in the scope. to show the signal, click the signal name again. to show only one signal, right-click the signal name. to show all signals, press esc.

tunable: yes

dependencies

to enable this property, set the viewtype property to "spectrum" or "spectrum and spectrogram".

scope window use

click the analyzer tab on the spectrum analyzer toolstrip. to see the legend, click legend in the configuration section.

to enable the legend, select spectrum in the analyzer tab.

data types: logical

channel names in the input data, specified as a cell array of character vectors or an array of strings. the names you specify in this property appear in the following locations:

  • legend

  • spectrum analyzer settings > color and styling section

  • measurements and channel measurements tabs

if you do not specify channel names, the spectrum analyzer names the channels as channel 1, channel 2, and so on.

tunable: yes

dependency

to see the channel names, set showlegend to true.

scope window use

click the analyzer tab on the spectrum analyzer toolstrip. to see the legend, click legend in the configuration section.

data types: char

flag to show the grid, specified as true or false. set this property to true to show grid lines in the plot.

tunable: yes

scope window use

click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that appears, under display and labels, select show grid.

data types: logical

y-axis limits, specified as a two-element numeric vector of the form [ymin ymax]. the units of the y-axis limits depend on the spectrumunits property.

example: scope.ylimits = [-10,20]

tunable: yes

dependencies

  • to enable this property, set the viewtype property to "spectrum" or "spectrum and spectrogram".

  • the units directly depend upon the spectrumunits property.

scope window use

click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that opens up, under display and labels, enter y-axis limits.

to enable the y-axis limits, select spectrum in the analyzer tab.

color limits of the spectrogram, specified as a two-element numeric vector of the form [colormin colormax]. the units of the color limits directly depend upon the spectrumunits property.

example: scope.colorlimits = [-10,20]

tunable: yes

dependencies

  • to enable this property, set the viewtype property to "spectrogram" or "spectrum and spectrogram".

  • the units directly depend upon the spectrumunits property.

scope window use

click the analyzer tab on the spectrum analyzer toolstrip. in the configuration section, click settings. in the spectrum analyzer settings window that opens up, under display and labels, enter color limits.

to enable the color limits, select spectrogram in the analyzer tab.

axes scaling mode, specified as one of these:

  • "auto" — the scope scales the axes to fit the data, both during and after simulation.

  • "manual" — the scope does not scale the axes automatically.

  • "onceatstop" — the scope scales the axes when the simulation stops.

  • "updates" — the scope scales the axes after a specific number of visual updates. it determines the number of updates using the axesscalingnumupdates property.

tunable: yes

data types: char | string

layout of the axes, specified as one of "vertical" or "horizontal". a vertical layout stacks the spectrum above the spectrogram. a horizontal layout puts the two views side-by-side.

tunable: yes

dependency

to enable this property, set viewtype to "spectrum and spectrogram".

scope window use

click the analyzer tab on the spectrum analyzer toolstrip. select spectrum and spectrogram. in the configuration section, select and update layout.

data types: char | string

usage

description

scope(signal) updates the spectrum of the signal in the spectrum analyzer.

example

scope(signal1,signal2,...,signaln) displays multiple signals in the spectrum analyzer. the signals must have the same frame length, but can vary in number of channels. you must set the numinputports property to enable multiple input signals.

input arguments

specify one or more input signals to visualize in the dsp.spectrumanalyzer. signals can have a different number of channels, but must have the same frame length.

example: scope(signal1, signal2)

data types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

object functions

to use an object function, specify the system object as the first input argument. for example, to release system resources of a system object named obj, use this syntax:

release(obj)
generate matlab script to create scope with current settings
get the current measurement data displayed on the spectrum analyzer
get test results of current spectral mask
save spectrum data shown in spectrum analyzer
check spectrum analyzer for new data
display scope window
hide scope window
determine visibility of scope
run system object algorithm
release resources and allow changes to system object property values and input characteristics
reset internal states of system object

if you want to restart the simulation from the beginning, call reset to clear the scope window displays. do not call reset after calling release.

examples

view a one-sided power spectrum made from the sum of fixed real sine waves with different amplitudes and frequencies.

fs = 100e6;  % sampling frequency
fsz = 5000;  % frame size
sin1 = dsp.sinewave(1e0,  5e6,0,'samplesperframe',fsz,'samplerate',fs);
sin2 = dsp.sinewave(1e-1,15e6,0,'samplesperframe',fsz,'samplerate',fs);
sin3 = dsp.sinewave(1e-2,25e6,0,'samplesperframe',fsz,'samplerate',fs);
sin4 = dsp.sinewave(1e-3,35e6,0,'samplesperframe',fsz,'samplerate',fs);
sin5 = dsp.sinewave(1e-4,45e6,0,'samplesperframe',fsz,'samplerate',fs);
scope = dsp.spectrumanalyzer;
scope.samplerate = fs;
scope.spectralaverages = 1;
scope.plotastwosidedspectrum = false;
scope.rbwsource = 'auto';
scope.powerunits = 'dbw';
for idx = 1:1e2 
     y1 = sin1();
     y2 = sin2();
     y3 = sin3();
     y4 = sin4();
     y5 = sin5();
     scope(y1 y2 y3 y4 y5 0.0001*randn(fsz,1));
end

run the release method to let property values and input characteristics change. the scope automatically scales the axes.

release(scope)

run the clear function to close the spectrum analyzer window.

clear('scope');

view a two-sided power spectrum of a sine wave with noise on the spectrum analyzer.

sin = dsp.sinewave('frequency',100,'samplerate',1000);
sin.samplesperframe = 1000;
scope = dsp.spectrumanalyzer('samplerate',sin.samplerate);
for ii = 1:250
  x = sin()   0.05*randn(1000,1);
  scope(x);
end

run the release method to change property values and input characteristics. the scope automatically scales the axes. it updates the display one more time if any data is in the internal buffer.

release(scope);

run the matlab clear function to close the spectrum analyzer window.

clear('scope');

this example shows the spectrogram for a chirp signal with added random noise.

fs = 233e3;
framesize = 20e3;
chirp = dsp.chirp('samplerate',fs,...
  'samplesperframe',framesize,...
  'initialfrequency',11e3,...
  'targetfrequency',11e3 55e3);
scope = dsp.spectrumanalyzer('samplerate',fs);
scope.viewtype = 'spectrogram';
scope.rbwsource = 'property';
scope.rbw = 500;
scope.timespansource = 'property';
scope.timespan = 2;
scope.plotastwosidedspectrum = false;
for idx = 1:50
  y = chirp()  0.05*randn(framesize,1);
  scope(y);
end
release(scope)

use the spectrum analyzer to display frequency input from spectral estimates of sinusoids embedded in white gaussian noise.

initialization

initialize two dsp.spectrumestimator objects to display. set one object to use the welch-based spectral estimation technique with a hann window, set the other object use a filter bank estimation. specify a noisy sine wave input signal with four sinusoids at 0.16, 0.2, 0.205, and 0.25 cycles/sample. view the spectral estimate using a third object, a spectrum analyzer, set to process frequency input.

framesize = 420;
fs = 1;
frequency = [0.16 0.2 0.205 0.25];
sinegen = dsp.sinewave('samplerate',fs,'samplesperframe',framesize,...
    'frequency',frequency,'amplitude',[2e-5 1  0.05  0.5]);
noisevar = 1e-10;
numavgs = 8;
hannestimator = dsp.spectrumestimator('powerunits','dbm',...
    'window','hann','frequencyrange','onesided',...
    'spectralaverages',numavgs,'samplerate',fs);
filterbankestimator = dsp.spectrumestimator('powerunits','dbm',...
    'method','filter bank','frequencyrange','onesided',...
    'spectralaverages',numavgs,'samplerate',fs);
spectrumplotter = dsp.spectrumanalyzer('inputdomain','frequency',...
    'samplerate',fs,...
    'spectrumunits','dbm','ylimits',[-120,40],...
    'plotastwosidedspectrum',false,...
    'channelnames',{'hann window','filter bank'},'showlegend',true);

streaming

stream the input. compare the spectral estimates in the spectrum analyzer.

for i = 1:1000
    x = sum(sinegen(),2)   sqrt(noisevar)*randn(framesize,1);
    pse_hann = hannestimator(x);
    pfb = filterbankestimator(x);
    spectrumplotter([pse_hann,pfb])
end

compute and display the power spectrum of a noisy sinusoidal input signal using the dsp.spectrumanalyzer system object. measure the peaks, cursor placements, adjacent channel power ratio, and distortion in the spectrum by enabling the following properties:

  • peakfinder

  • cursormeasurements

  • channelmeasurements

  • distortionmeasurements

initialization

the input sine wave has two frequencies: 1000 hz and 5000 hz. create two dsp.sinewave system objects to generate these two frequencies. create a dsp.spectrumanalyzer system object to compute and display the power spectrum.

fs = 44100;
sineobject1 = dsp.sinewave('samplesperframe',1024,...
    'phaseoffset',10,...
    'samplerate',fs,'frequency',1000);
sineobject2 = dsp.sinewave('samplesperframe',1024,...
    'samplerate',fs,'frequency',5000);
sa = dsp.spectrumanalyzer('samplerate',fs,'method','filter bank',...
    'spectrumtype','power','plotastwosidedspectrum',false,...
    'channelnames',{'power spectrum of the input'},...
    'ylimits',[-120 40],'showlegend',true);

enable measurements data

to obtain the measurements, set the enable property of the measurements to true.

sa.cursormeasurements.enable = true;
sa.channelmeasurements.enable = true;
sa.peakfinder.enable = true;
sa.distortionmeasurements.enable = true;

use getmeasurementsdata

stream in the noisy sine wave input signal and estimate the power spectrum of the signal using the spectrum analyzer. measure the characteristics of the spectrum. use the getmeasurementsdata function to obtain these measurements programmatically. the isnewdataready function indicates when there is new spectrum data. the measured data is stored in the variable data.

data = [];
for iter = 1:1000
    sinewave1 = sineobject1();
    sinewave2 = sineobject2();
    input = sinewave1   sinewave2;
    noisyinput = input   0.001*randn(1024,1);
    sa(noisyinput);
     if sa.isnewdataready
        data = [data;getmeasurementsdata(sa)];
     end
end

the right side of the spectrum analyzer shows the enabled measurement panes. the values shown in these panes match with the values shown in the last time step of the data variable. you can access the individual fields of data to obtain the various measurements programmatically.

compare peak values

peak values are obtained by the peakfinder property. verify that the peak values obtained in the last time step of data match the values shown on the spectrum analyzer plot.

peakvalues = data.peakfinder(end).value 
peakvalues = 3×1
   26.9851
   24.1735
  -51.1973
frequencieskhz = data.peakfinder(end).frequency/1000
frequencieskhz = 3×1
    4.9957
    0.9905
    0.2369

tips

  • to close the scope window and clear its associated data, use the matlab function.

  • to hide or show the scope window, use the and functions.

  • use the matlab mcc function to compile code containing a spectrum analyzer.

    you cannot open spectrum analyzer configuration dialog boxes if you have more than one compiled component in your application.

algorithms

extended capabilities

version history

introduced in r2012b

see also

objects

blocks

topics

    网站地图