필터 지우기
필터 지우기

Incorrect autoscaling during plot command in matlab

조회 수: 5 (최근 30일)
Samuel
Samuel 2011년 9월 26일
Hello guys, first time poster. I just had a question about my code- I am just trying to plot some data that I imported from a csv file, but the plot itself leaves voids.
I haven't done anything to change the settings.
The code:
clear all; close all; clc
t = load('sampledata.csv');
time=t(1:125000,1);
gage=t(1:125000,2);
plot(time,gage)
xlabel('Sample Number')
ylabel('volts')
title('{\bf Oscilloscope Data}')
below is the image i got from the plot. http://img220.imageshack.us/img220/4417/oscilloscope.jpg
any help or advice will be appreciated. thanks!
sam
  댓글 수: 5
Samuel
Samuel 2011년 9월 30일
To all, thanks for the response! @walter- how did you manage to embed the image? I wasn't able to find the command to embed the image.
@fangjun- I actually mean't that the plot axes stretches, so to say, farther than the data needs. Especially if you see at -.5, there is an empty space where there are no values. Same follows for the top and bottom axes.
Walter Roberson
Walter Roberson 2011년 10월 2일
To embed an image, use a separate paragraph and start it with << followed immediately (no space after << ) by the URL to the image directly, followed immediately (no space after URL) by >>
The tricky part is often in finding the direct URL for the image, especially if you do not have an account on the system being used to host the image. For situations like that, I display the image in my browser, position my cursor over it, right-click, and choose "Copy image location". That URL is then the one I paste in to the posting.

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

답변 (2개)

Bjorn Gustavsson
Bjorn Gustavsson 2011년 9월 26일
That figure looks OK to me I guess. "Guess" since I dont know what your data going in was...
What points are you missing?
Do you want a tighter fit of the plot around the points? Then you should could do:
axis tight
Beside that not much to go on here.
HTH
  댓글 수: 4
Samuel
Samuel 2011년 9월 30일
Sorry for not being so clear guys.
What I would like to have change from this plot will be so that the data axis will be from -10 to 10 on the y axis, and ~.4 to 2.5 for the x axis(just to encompass the data), automatically, after I plot.
This is probably a rather simple problem with a VERY easy solution- any help will be appreciated.
Thanks
Sam
Fangjun Jiang
Fangjun Jiang 2011년 9월 30일
axis([XMIN XMAX YMIN YMAX])

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


Samuel
Samuel 2011년 9월 30일
Thanks Bjorn-
I actually tried "axis tight", and this ALMOST is what I need.. not quite, because I noticed that some data gets cut off from the plot. Still looking- thanks for the suggestion though.
Sam
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 9월 30일
set(gca, 'Xlim', [min(time),max(time)], 'YLim', [min(gage),max(gage)])
Samuel
Samuel 2011년 10월 1일
that is exactly what I need. Thanks very much walter!

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

Community Treasure Hunt

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

Start Hunting!

Translated by