%% Set Cursor Labels on dsp.MatrixViewer
% This example shows how to set the data labels for the cursor measurements on the dsp.MatrixViewer System object.
% Display a chirp signal on the dsp.MatrixViewer scope.

Fs = 233e3;
frameSize = 20e3;
chirp = dsp.Chirp("SampleRate",Fs,"SamplesPerFrame",frameSize,...
  "InitialFrequency",11e3,"TargetFrequency",11e3+55e3,...
  "Type","Quadratic");
scope = dsp.MatrixViewer(...
    "ColorBarLabel","Power/Frequency (dB/Hz)",...
    "XLabel","Frequency (Hz)",...
    "YLabel","Time (secs)",...
    "Colormap","hsv",...
    "ColorLimits",[-100,-30]);
y = chirp() + 0.05*randn(frameSize,1);
[~,~,~,Ps] = spectrogram(y,128,120,128,1e3);
val = 10*log10(abs(Ps)'+eps);
scope(val);

%
% Change the data labels for the cursor measurements to match the type of data in the matrix.

setCursorDataLabels(scope,["Hz","Sec","db/Hz"])

%
% Enable the cursor measurements by selecting the cursor button in the axes toolbar. When you hover over the cursor, the tooltip shows you the data values with the new data labels.
%
% Copyright 2018 The MathWorks, Inc.