필터 지우기
필터 지우기

My plot does not start at 0

조회 수: 328 (최근 30일)
aryan abedi
aryan abedi 2017년 7월 18일
편집: Harley Calvert 2021년 11월 21일
I had to write this code, to plot an ecg trace, however, after writing I realized my graph does not start on the x axis. I tried to define limits for my axis but it still did not work. Also my graph does not fit the scale. I want the x axis ends right at the last point of my graph but that does not happen either. I was wondering if someone can help me.
  댓글 수: 2
MSP
MSP 2017년 7월 18일
Can you post the text file that you used
the cyclist
the cyclist 2017년 7월 18일
편집: the cyclist 2017년 7월 18일
It's probably impossible to help you without seeing your data and/or code. Please post them.
Also, I deleted the first (nearly identical) question you posted.

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

답변 (3개)

Image Analyst
Image Analyst 2017년 7월 18일
If you want your data to start from the x ("t") axis, so that only positive y ("v") are shown, and no negative y/v, then do this:
yl = ylim; % Get current limits.
ylim([0, yl(2)]); % Replace lower limit only with a y of 0.
If you want x/t to start at the y/volts axis, and end at the last t, do this:
xlim([0, t(end)]);
Do both of those after you've called plot(), not before.
  댓글 수: 2
aryan abedi
aryan abedi 2017년 7월 19일
Thanks for your help. xlim did work, but the Y one does not work, I have an ecg graph, which I detrend it and that is why it starts below the 0. If i define boundaries for y (the code you gave me) it cuts off the negative part of the ecg trace. Thanks again for your help on the xlim.
Image Analyst
Image Analyst 2017년 7월 19일
When you said " I realized my graph does not start on the x axis" I assumed you wanted the graph (the y axis) to start at the x axis (the horizontal line, the horizontal axis) and go upwards from there. What else could it mean? You can pass whatever values you want for the starting and stopping values of the y axis into ylim().

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


dbmn
dbmn 2017년 7월 19일
The question is not really clear and multiple outcomes are possible. Maybe you could draw (into the image you posted, what you want it to look like)
% Move x axis around (I dont like how it looks, but maybe thats what you want)
ax = gca;
ax.XAxisLocation = 'origin';
% Other limits of y axis (basically copied from Image Analyst but tweaked a little bit)
yl = ylim;
ylim([min(y), max(y)]);

Harley Calvert
Harley Calvert 2021년 11월 21일
편집: Harley Calvert 2021년 11월 21일
I had a problem like this and I just made a second plot going from 0 to the 1st point...
two = [0; one(1,1)];
plot(one)
plot(0:1, two)
You have to play with the line and colors etc to make it match.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by