plot two data sets over different time in the same plot

조회 수: 30 (최근 30일)
Howie
Howie 2013년 5월 13일
Hi,
I have two sets of data, say x = 1:10; y = [0,0,3:10] now I want to plot the data points over time t = 1:10 The thing is I do not want to see the 0-value points of y. or put in another way, I want to plot x over selected time t and y over t2. t2 = 3:10 in this case.
If I directly use y(t2) to add on, then the x axis for that plot will starts from 0, instead of 3 as desired!
Thanks, Howie
  댓글 수: 1
Howie
Howie 2013년 5월 13일
I am asking for two data sets(matrices), not functions. The rules are a little bit different. so if the time has a dimension different than the data, it simply cannot plot. Thanks, Howie

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

답변 (2개)

Yao Li
Yao Li 2013년 5월 13일
plot(t,x)
hold on
plot(t2,y)
  댓글 수: 14
Howie
Howie 2013년 5월 13일
yes! connecting all thye x; connecting all the y
Yao Li
Yao Li 2013년 5월 14일
connect x to y, or connect a point of x to the next point of x?

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


Jakob Sørensen
Jakob Sørensen 2013년 5월 13일
Here is an example of how it can be done:
t1 = linspace(0,2*pi,100);
t2 = linspace(pi,2*pi,50);
y1 = sin(t1);
y2 = cos(t2);
plot(t1,y1,t2,y2);
Gives you a plot of a sine (y1) and a cosine (y2), where the cosine only exists from pi:2*pi.
  댓글 수: 6
Howie
Howie 2013년 5월 13일
편집: Howie 2013년 5월 13일
So here comes the problem. if I just do that, then 0-values of y will be plotted. but all I want is 3:10. I do not think I can do it just by selecting columns since my goal is to remove the points, without changing the position of the points
(I want the first point of y to be(3,3), not (1,3)).
Maybe I was doing it all wrong.
Yao Li
Yao Li 2013년 5월 14일
so why not just create a new array which stores only the required points?

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

카테고리

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