Main Content

Signal Visualization and Measurements in MATLAB

此示例显示了如何使用时间范围和频谱分析仪在MATLAB®中的时间和频域中可视化和测量信号。

时间和频域中的信号可视化

创建以1000 Hz采样频率为100 Hz的正弦波。在100 Hz正弦波中产生五秒钟 n (( 0 ,,,, 0 0 0 2 5 一秒钟的间隔白噪声。将信号发送到时间范围和频谱分析仪进行显示和测量。

sampperframe = 1000;FS = 1000;SW = DSP.SineWave('Frequency',100,...'采样率',,,,Fs,...'SamplesPerFrame',sampperframe);ts = timeScope('采样率',,,,Fs,...'TimeSpanSource',,,,'财产',,,,...'时间跨度',0.1,...'YLimits',,,,[-2, 2],...'ShowGrid',真的);sa =光谱分析仪('采样率',,,,Fs,...'方法',,,,'韦尔奇',,,,'AveragingMethod',,,,“指数”);tic;whiletoc <10 sigdata = sw() + 0.05*randn(sampperframe,1);SA(Sigdata);TS(Sigdata);结尾释放(TS)

释放(SA)

时间域测量

使用时间范围,您可以进行许多时间域信号测量。

这following measurements are available:

  • Cursor Measurements- 将屏幕光标放在所有范围显示上。

  • Signal Statistics- 显示最大,最小值,峰值差异,平均值,中值,所选信号的RMS值以及最大和最小值的时间。

  • 仅二重测量-Displays information about a selected signal's transitions, aberrations, and cycles.

  • Peak Finder-Displays maxima and the times at which they occur.

You can enable and disable these measurements from the测量t一个b。

为了说明在时间范围中测量的使用,请模拟ECG信号。使用eCgfunction to generate 2700 samples of the signal. Use a Savitzky-Golay filter to smooth the signal and periodically extend the data to obtain approximately 11 periods.

x = 3.5*ecg(2700).'; y = repmat(sgolayfilt(x,0,21),[1 13]); sigData = y((1:30000) + round(2700*rand(1))).';

Display the signal in the time scope and use the Peak Finder and Data Cursor measurements. Assume a sample rate of 4 kHz.

ts_ecg = timescope('采样率',,,,4000,...'TimeSpanSource',,,,'汽车',,,,...'ShowGrid',,,,true); TS_ECG(sigData); TS_ECG.YLimits = [-4, 4];

Peak Measurements

使能够Peak Measurementsfrom the测量通过单击相应的工具分按钮来选项卡。这Peaks pane appears at the bottom of the time scope window. For thenum Peaksproperty, enter8然后按Enter。在峰窗格中,时间范围显示了8个峰值幅度值及其发生的时间。

每个心跳之间的恒定时间差为0.675秒。因此,ECG信号的心率由以下方程式给出:

6 0 s e C / m 一世 n 0 6 7 5 s e C / b e 一个 t = 8 8 8 9 b e 一个 t s / m 一世 n (( b p m

Cursor Measurements

使能够Cursor Measurementsfrom the测量通过单击相应的工具分按钮来选项卡。光标出现在时间范围上,其中一个盒子显示了两个光标之间的时间和值的变化。您可以拖动光标并使用它们来测量波形中事件之间的时间。当您拖动光标时,出现光标处的值的时间。该图显示了如何使用光标来测量ECG波形中峰之间的时间间隔。这 Δ t 光标盒中的测量表明,两个峰之间的时间间隔为0.675秒,对应于1.482 Hz或88.9次/分钟的心率。

Signal Statistics一个nd仅二重测量

You can also selectSignal Statistics一个nd various bilevel measurements from the测量t一个b。Signal Statistics can be used to determine the signal's minimum and maximum values as well as other metrics like the peak-to-peak, mean, median, and RMS values. Bilevel measurements can be used to determine information about rising and falling transitions, transition aberrations, overshoot and undershoot information, settling time, pulse width, and duty cycle. To read more about these measurements, see配置时间范围MATLAB对象

频域测量

this section explains how to make frequency domain measurements with the spectrum analyzer.

频谱分析仪提供以下测量:

  • Cursor Measurements- 将光标放在频谱显示屏上。

  • Peak Finder-displays maxima and the frequencies at which they occur.

  • Channel Measurements- 显示占据的带宽和ACPR通道测量值。

  • Distortion Measurements-displays harmonic and intermodulation distortion measurements.

您可以从Spectrum Analyzer工具条中启用和禁用这些测量结果。

Distortion Measurements

为了说明使用Spectrum Analyzer的测量方法的使用,请创建一个2.5 kHz的正弦波,并在48 kHz中采样带有添加剂白色高斯噪声。在每个信号值下评估高阶多项式(9度),以模拟非线性失真。在频谱分析仪中显示信号。

FS = 48E3;SW = DSP.SineWave('Frequency',,,,2500,,,,...'采样率',,,,Fs,...'SamplesPerFrame',sampperframe);sa_distortion = spectrumanalyaler('采样率',,,,Fs,...'方法',,,,'韦尔奇',,,,...'AveragingMethod',,,,“指数”,,,,...'PlotAsTwoSidedSpectrum',错误的);y = [1E-6 1E-9 1E-5 1E-9 1E-6 5E-8 0.5E-3 1E-6 1 3E-3];tic;whiletoc <5 x = sw() + 1e-8*randn(sampperframe,1);sigdata = polyval(y,x);sa_distortion(sigdata);结尾释放(sa_distortion);

通过选择Distortion按钮测量频谱分析仪工具条的选项卡。In theDistortionseCt一世on, change the value for数字谐波到9并检查标签谐波Checkbox. In the Harmonic Distortion panel at the bottom of the spectrum analyzer window, you see the value of the fundamental close to 2500 Hz and 8 harmonics as well as their SNR, SINAD, THD and SFDR values, which are referenced with respect to the fundamental output power.

Peak Finder

您可以使用峰查找器测量值跟踪时变光谱组件。您可以显示并可选地标记高达100个峰。要调用峰查找器,请选择Peak Finder按钮测量频谱分析仪工具条的选项卡。

说明使用的使用Peak Finder,,,,Create a signal consisting of the sum of three sine waves with frequencies of 5, 15, and 25 kHz and amplitudes of 1, 0.1, and 0.01 respectively. The data is sampled at 100 kHz. Add n (( 0 ,,,, 1 0 - 8 高斯白噪声的正弦波之和display the one-sided power spectrum in the spectrum analyzer.

Fs = 100e3; SW1 = dsp.SineWave(1e0,5e3,0,...'采样率',,,,Fs,...'SamplesPerFrame',sampperframe);sw2 = dsp.SineWave(1e-1,15e3,0,...'采样率',,,,Fs,...'SamplesPerFrame',sampperframe);sw3 = dsp.SineWave(1e-2,25e3,0,...'采样率',,,,Fs,...'SamplesPerFrame',sampperframe);SA_Peak = spectrumAnalyzer('采样率',,,,Fs,...'方法',,,,'韦尔奇',,,,...'AveragingMethod',,,,“指数”,,,,...'PlotAsTwoSidedSpectrum',错误的);tic;whiletoc <10 sigdata = sw1() + sw2() + sw3() + 1e-4*randn(sampperframe,1);sa_peak(sigdata);结尾释放(sa_peak);

使能够thePeak Finderto label the three sine wave frequencies. The frequency values and powers in dBm are displayed below the plot. You can increase or decrease the maximum number of peaks, specify a minimum peak distance, and change other settings in thePeaks部分测量t一个b。

要了解有关使用Spectrum Analyzer使用测量的更多信息,请参见Spectrum Analyzer Measurementsexample.