plot help
1 回表示 (過去 30 日間)
古いコメントを表示
Hello
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);
pause(0.5);
w = waitforbuttonpress;
if w == 1
win_xlimit = win_xlimit + offset;
end
end
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?
Thanks
0 件のコメント
採用された回答
Walter Roberson
2011 年 8 月 15 日
See linkaxes()
2 件のコメント
Walter Roberson
2011 年 8 月 15 日
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.
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!