Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

isNewDataReady

Check spectrum analyzer for new data

Syntax

flag = isNewDataReady(scope)

Description

example

flag = isNewDataReady(scope) indicates whether or not the spectrum analyzer scope displays new spectrum estimates. When you are logging spectrum analyzer data from the dsp.SpectrumAnalyzer scope, use this function to ignore duplicate spectrums from the getSpectrumData function.

Examples

collapse all

While a spectrum analyzer is running, save the spectrum data to a table. The spectrum analyzer does not update at every time step. To avoid saving that redundant spectrum data, use the isNewDataReady function.

wave = dsp.SineWave('Frequency',100,'SampleRate',1000);
wave.SamplesPerFrame = 1000;
scope = dsp.SpectrumAnalyzer('SampleRate',wave.SampleRate,...
    'ReducePlotRate',false,...
    'ViewType','Spectrum and spectrogram');
data = [];

for ii = 1:250
    x = wave() + 0.05*randn(1000,1);
    scope(x);
    if scope.isNewDataReady
        data = [data;getSpectrumData(scope)];
    end
end

release(scope);

In the data table, you can see gaps in the simulation time. These missing rows indicate times where the spectrum analyzer was waiting for additional samples to update the spectrum. The isNewDataReady function prevented the script from saving that redundant data.

data(1:5,:)
ans =

  5x6 table

    SimulationTime       Spectrum           Spectrogram       MinHoldTrace    MaxHoldTrace    FrequencyVector
    ______________    _______________    _________________    ____________    ____________    _______________

    [1]               [1536x1 double]    [100x1536 double]    []              []              [1536x1 double]
    [3]               [1536x1 double]    [100x1536 double]    []              []              [1536x1 double]
    [4]               [1536x1 double]    [100x1536 double]    []              []              [1536x1 double]
    [6]               [1536x1 double]    [100x1536 double]    []              []              [1536x1 double]
    [7]               [1536x1 double]    [100x1536 double]    []              []              [1536x1 double]

Input Arguments

collapse all

Spectrum analyzer that you want to save data from.

Output Arguments

collapse all

true

The spectrum analyzer shows new data.

false

The spectrum analyzer shows the same spectrum as the last time the scope was called.

Introduced in R2017b

Was this topic helpful?