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+*o.sd^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; end % set(c,'ShowText','off','TargetMarkerSize',12,'TargetMarkerFaceColor','w')
Published with MATLAB® R2017a
2 CommentsOldest to Newest
Marjorie’s utility mentions my webpage, where I explain the undocumented/unsupported graphics.cursorbar feature, as the source for her submission: http://undocumentedmatlab.com/blog/undocumented-cursorbar-object
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.
Edit: it seems that this utility is actually not Marjorie’s, but rather Yaroslav Don’s (at least originally), which was simply posted under Marjorie’s name. See the discussion here: http://undocumentedmatlab.com/blog/undocumented-cursorbar-object#comment-344617