Data disappears from plot when setting axes limits?
7 次查看(过去 30 天)
显示 更早的评论
I'm trying to display a figure with three plots on it. The data in the third is of lower amplitude than the first two plots, and as such Matlab defaults to setting a smaller scale. I want to be able to set the axes limits on all three, however when I do the plots return with no data in them. I've tried moving the axes limits to what it would set them to by default and the problem still persists
My code is as follows,
figure
ax1 = subplot(3,1,1);
plot(IN1);
xlim([0 0.3]);
ylim([-0.01 0.01]);
xlabel('Time');
ylabel('Amplitude');
ax2 = subplot(3,1,2);
plot(IN2);
xlim([0 0.3]);
ylim([-0.01 0.01]);
xlabel('Time');
ylabel('Amplitude');
ax3 = subplot(3,1,3);
plot(IN3);
xlim([0 0.3]);
ylim([-0.01 0.01]);
xlabel('Time');
ylabel('Amplitude');
If I comment out the xlim & ylim functions it works fine. (See pictures below) I'm running R2015B on an Imac running macOS10.15
Any help would be greatly appreciated!


0 个评论
采纳的回答
Walter Roberson
2018-6-9
You have no data in the first 0.3 seconds.
You are plotting without an explicit x axis, so it is going to assume that the x axis is 1 to the length of your data, which is about 10^5 samples. Your first sample time is therefore 1. You have nothing between 0 and 0.3.
You might need something like
plot(t, IN1)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!