How to change the scaling of columns in an array to a different scaling of the same data points on a plot?

조회 수: 1 (최근 30일)
Hi, I didn't really know how to frame my problem so sorry if it's unclear, but here it is: basically I have a variable which is an array of data with 6 data points (6 columns, 1 row). I now want to plot these, but if you just use 'plot', then it ends up putting the first data point as corresponding with "1" on the x axis, the second data point with "2" etc. whereas I want the first data point to correspond to something else - let's say 5 on the x axis, the next one to 20 and then 30 etc. (e.g. data point is distance and the first one is at 5 seconds, the second one at 20 seconds, the next one at 30 etc.).
To work around this I tried creating a different array with the data points being in corresponding columns (and zeros for the rest of the columns) but that just ended up plotting whole lot of zeros in-between to.
To get rid of the zeros, I tried to change them to NaN with
Distance(Distance==0)=nan
which almost worked but if I try to plot this now, I just end up with 6 data points and I can't seem to get a line to connect them?
Any help would be much appreciated!

채택된 답변

jonas
jonas 2018년 9월 5일
편집: jonas 2018년 9월 5일
Excuse me if I misunderstand the question, but my take away is that you are asking how to use the basic plot function. Consider y to be your array with values. The corresponding x-values then goes into the x-vector:
x = [5 20 30...]
plot(x,y)
  댓글 수: 1
Shanaja
Shanaja 2018년 9월 5일
Oh my, feel super stupid right now, it actually was what I was asking about! Got too caught up in the fancy difficult stuff. Thank you so much and let me go bury myself in a hole somewhere

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

추가 답변 (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