Data disappears from plot when setting axes limits?

조회 수: 7 (최근 30일)
Joshua Stephen
Joshua Stephen 2018년 6월 9일
댓글: Joshua Stephen 2018년 6월 9일
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!

채택된 답변

Walter Roberson
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)
  댓글 수: 1
Joshua Stephen
Joshua Stephen 2018년 6월 9일
Can't believe I missed the 10^5. Thanks! Forgot I was working with samples rather than seconds with this plot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by