File Exchange Pick of the Week

Our best user submissions

This is machine translation

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

Cursorbar 2

Posted by Sean de Wolski,

Sean‘s pick this week is Cursorbar by Marjorie.

I really like both Simulink Data Inspector and the new Signal Analyzer App for comparing and analyzing signal data. They make it easy to rapidly compare lots of signals, and with the Signal Analyzer to see the spectrum and spectrogram in the same window as the signal. Additionally, they also have data cursors that allow me to scan the values of multiple signals at the same time. Here’s a screen shot of all of the features I just mentioned:

So what if you want a data cursor on a regular MATLAB plot? Well now you can with Marjorie’s cursorbar. Cursorbar gives you plenty of control over its appearance and behavior to meet all of your data cursor needs.

Look at the help for a whole slew of examples! Here’s the 9th one:

% Create line plot
x = linspace(0,14,201);
y = sin(2*pi*x/3);
h = plot(x,y,':k','LineWidth',2);
ylim([-1.2 1.2])

% Define colors
topMarkers = 'x+*o.sdv^><ph'; % top marker styles
bottomMarkers = 'x+*^v<>hp'; % bottom marker styles
targetMarkers = '+xo*.dsddddhp'; % target marker styles
lineColor = lines(13); % cursorbar colors

% Create cursorbars
for ii=13:-1:1
    c(ii) = graphics.Cursorbar(h,'Location',ii);
    c(ii).TopMarker = topMarkers(ii);
    c(ii).BottomMarker = bottomMarkers(ii);
    c(ii).TargetMarkerStyle = targetMarkers(ii);
    c(ii).CursorLineColor = lineColor(ii,:);
    c(ii).TargetMarkerEdgeColor = 1-lineColor(ii,:);
    c(ii).TopHandle.MarkerSize = 12;
    c(ii).BottomHandle.MarkerSize = 12;


Give it a try and let us know what you think here or leave a comment for Marjorie.

Get the MATLAB code

Published with MATLAB® R2017a


Comments are closed.

2 CommentsOldest to Newest

Yair Altman replied on : 1 of 2

Marjorie’s utility mentions my webpage, where I explain the undocumented/unsupported graphics.cursorbar feature, as the source for her submission:

Note that graphics.cursorbar itself was removed from Matlab in R2014b. Apparently, Marjorie took its original code, adapted it for the new graphics engine (HG2, introduced in R2014b), and extensively improved it along the way. The result is indeed very useful and capable.

Some users may want to shy away from utilities that rely on undocumented/unsupported aspects, since they might stop working properly in some future Matlab release. But if you drill down into Marjorie’s code you’d see that it does not rely on graphics.cursorbar (which is defunct as noted), and so her code cannot really be said to rely on undocumented features.