getSpectralMaskStatus
Get test results of current spectral mask
Description
Examples
Add a spectral mask to an existing spectrumAnalyzer object. Use the getSpectralMaskStatus function to get the spectral mask status.
sine = dsp.SineWave(Frequency=[98 100],SampleRate=1000); sine.SamplesPerFrame = 1024; scope = spectrumAnalyzer(SampleRate=sine.SampleRate,... PlotAsTwoSidedSpectrum=false,ShowLegend=true,YLimits=[-60 40]); hide(scope); scope.SpectralMask.EnabledMasks = "upper-and-lower"; upperMask = [0 -10; 90 -10; 90 30; 110 30; 110 -10; 500 -10]; set(scope.SpectralMask,UpperMask=upperMask,LowerMask=-55); for i=1:100 scope(sine() + 0.05*randn(1024,2)); end res = getSpectralMaskStatus(scope)
res = struct with fields:
IsCurrentlyPassing: 1
NumPassedTests: 44
NumTotalTests: 51
SuccessRate: 86.2745
FailingMasks: ''
FailingChannels: [1×0 double]
SimulationTime: 102.3990
You can also view the status in the Spectral Mask tab on the Spectrum Analyzer toolstrip.
show(scope); release(scope);

Input Arguments
Spectrum Analyzer with spectral masks, specified as one of the following:
spectrumAnalyzerobjectSpectrumAnalyzerBlockConfigurationobject for a Spectrum Analyzer block
Output Arguments
Current status of the spectral mask, returned as a structure with these fields.
| Field | Description |
|---|---|
IsCurrentlyPassing | Pass status of one or more masks.
|
NumPassedTests | Number of mask tests that have passed |
NumTotalTests | Total number of mask tests |
SuccessRate | Percentage of tests that have passed |
FailingChannels | Array of channel numbers that have currently failed the mask test |
FailingMasks | Masks that have currently failed:
"none",
"upper",
"lower", or
"upper-and-lower" |
SimulationTime | Simulation time |
Version History
Introduced in R2017aThe dsp.SpectrumAnalyzer
System object™ warns in R2024a. Use the spectrumAnalyzer object instead.
Update Code
No updates to your code are required except replacing instances of
dsp.SpectrumAnalyzer with
spectrumAnalyzer.
This table shows how the getSpectralMaskStatus function
typically uses the dsp.SpectrumAnalyzer
System object and explains how to update existing code to use the
spectrumAnalyzer object.
| Discouraged Usage | Recommended Replacement |
|---|---|
Add a spectral mask to an existing
sine = dsp.SineWave('Frequency',[98 100],'SampleRate',1000); sine.SamplesPerFrame = 1024; scope = dsp.SpectrumAnalyzer('SampleRate',sine.SampleRate, ... 'PlotAsTwoSidedSpectrum',false,'ShowLegend',true,... 'YLimits',[-60 40]); hide(scope); scope.SpectralMask.EnabledMasks = 'Upper and lower'; upperMask = [0 -10; 90 -10; 90 30; 110 30; 110 -10; 500 -10]; set(scope.SpectralMask,'UpperMask',upperMask,'LowerMask',-55); for i=1:100 scope(sine() + 0.05*randn(1024,2)); end res = getSpectralMaskStatus(scope) res =
struct with fields:
IsCurrentlyPassing: 0
NumPassedTests: 1
NumTotalTests: 33
SuccessRate: 3.0303
FailingMasks: 'Upper and lower'
FailingChannels: [1 2]
SimulationTime: 101.3760You can see the same information in the Spectral Mask panel of the Spectrum Analyzer. show(scope); release(scope); | Add a spectral mask to an existing
The To retain
the same default behavior as the
sine = dsp.SineWave(Frequency=[98 100],SampleRate=1000); sine.SamplesPerFrame = 1024; scope = spectrumAnalyzer(SampleRate=sine.SampleRate,... PlotAsTwoSidedSpectrum=false,ShowLegend=true,... Method="welch",AveragingMethod="exponential",... ForgettingFactor=0.4,YLimits=[-60 40]); hide(scope); scope.SpectralMask.EnabledMasks = "upper-and-lower"; upperMask = [0 -10; 90 -10; 90 30; 110 30; 110 -10; 500 -10]; set(scope.SpectralMask,UpperMask=upperMask,LowerMask=-55); for i=1:100 scope(sine() + 0.05*randn(1024,2)); end res = getSpectralMaskStatus(scope) res = struct with fields:
IsCurrentlyPassing: 1
NumPassedTests: 32
NumTotalTests: 33
SuccessRate: 96.9697
FailingMasks: ''
FailingChannels: [1×0 double]
SimulationTime: 102.3990
You can see the same information in the Spectral Mask tab on the Spectrum Analyzer toolstrip. show(scope); release(scope); |
The getSpectralMaskStatus function will stop supporting the
dsp.SpectrumAnalyzer object in a future release. Use the
spectrumAnalyzer object instead.
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)