MATLAB Answers

plot help

1 view (last 30 days)
vsee on 15 Aug 2011
Here is matlab code that I am using to plot (analog and ttl signals of a waveform) and pan across the x-axis of the plot.
dsig = csvread('digital 1030 50Mhz 5M.csv',0,3);
asig = csvread('analog 1030 50Mhz 5M.csv',0,3);
%tim =sig(1:1000000,1);
damp = dsig(1:5000000,2);
aamp = asig(1:5000000,2);
ts = dsig(2,1) - dsig(1,1);
tim = [0:5000000 - 1]*ts;
time = tim';
subplot(2,1,1), plot(time, aamp);
subplot(2,1,2), plot(time, damp);
axis([0 max(tim) -0.1 1.5]);
ax_handle = gca;
xlimit_orig = get(ax_handle, 'Xlim');
win_xlimit = [0 0.0001];
offset = 0.0001;
%Iterativley change the xlimit for the axes to pan across the figure
while win_xlimit(2) <= xlimit_orig(2)
set(ax_handle, 'Xlim', win_xlimit);
w = waitforbuttonpress;
if w == 1
win_xlimit = win_xlimit + offset;
GCA seems to return axis handles to one of the plots. The panning works fine if I just plotted one signal and didn't use subplot. How can I pan across both plots using subplot?

Accepted Answer

Walter Roberson
Walter Roberson on 15 Aug 2011
See linkaxes()
Walter Roberson
Walter Roberson on 15 Aug 2011
Not as easily. pan works by modifying the axes limits, and there is no built-in functionality for keeping the same _relationship_ of axes limits between two axes.
It is possible, though. Have a look at the pan() documentation. Create pan mode objects for the two axes, and set the ActionPostCallback callbacks on those pan mode objects so that when one of the axes is panned, you set() the axes limits on the other to pan it to the desired relative location. The callbacks will need to know the relative offsets to use for the _other_ axes to know how to transform the limits for the current axes in to appropriate limits for the other axes.

Sign in to comment.

More Answers (0)



Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by