isNewDataReady
Check spectrum analyzer for new data
Description
indicates whether the spectrum analyzer flag = isNewDataReady(scope)scope displays new
spectral estimates. When logging spectrum analyzer data from the spectrumAnalyzer scope, use this function to ignore duplicate spectra
from the getSpectrumData function.
Examples
Generate a discrete sine wave. Then display the sine wave signal using the Spectrum Analyzer. While the 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 = spectrumAnalyzer(SampleRate=wave.SampleRate,... 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);

Show the first five rows in the table. You can see gaps in the simulation time in the data table. The 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 =
5×4 table
SimulationTime Spectrum Spectrogram FrequencyVector
______________ _______________ _________________ _______________
{[0.9990]} {1024×1 double} {100×1024 double} {1024×1 double}
{[1.9990]} {1024×1 double} {100×1024 double} {1024×1 double}
{[2.9990]} {1024×1 double} {100×1024 double} {1024×1 double}
{[4.9990]} {1024×1 double} {100×1024 double} {1024×1 double}
{[9.9990]} {1024×1 double} {100×1024 double} {1024×1 double}
Input Arguments
Spectrum analyzer from which you want to save data, specified as a
spectrumAnalyzer object.
Output Arguments
Flag indicating new data, returned as one of these:
true–– The Spectrum Analyzer shows new data.false–– The Spectrum Analyzer shows the same spectrum and no new data is available.
Version History
Introduced in R2017bThe 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 isNewDataReady function typically
uses the dsp.SpectrumAnalyzer
System object and explains how to update existing code to use the
spectrumAnalyzer object.
| Discouraged Usage | Recommended Replacement |
|---|---|
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); |
wave = dsp.SineWave(Frequency=100,SampleRate=1000); wave.SamplesPerFrame = 1000; scope = spectrumAnalyzer(SampleRate=wave.SampleRate,... 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); |
The isNewDataReady function will stop supporting the
dsp.SpectrumAnalyzer object in a future release. Use the
spectrumAnalyzer object instead.
See Also
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)