how to plot two figures in one figure with different axes

조회 수: 2 (최근 30일)
amirhossein sarfi
amirhossein sarfi 2019년 5월 13일
댓글: amirhossein sarfi 2019년 5월 13일
I am trying to plot flows collected in different time of the day for different days in the same plot. As the moments of collection are not exactly the same for each day the second plot is drawn in the continues of the first one:
whle I need them something like this:
  댓글 수: 2
Jan
Jan 2019년 5월 13일
And what are your inputs? If you post the relevant part of the code, we can suggest a modification. But without seeing the code, the readers have to invent it.
amirhossein sarfi
amirhossein sarfi 2019년 5월 13일
this is part of data for two different days:
d1.PNG
and
d2.PNG
and I use this script to import data:
filename = 'Rtest.xlsx';
sheet = '3';
xlRange = 'B2:E1441';
data1 = xlsread(filename, sheet,xlRange);
year1 = 2018;
month1 = 05;
day1 = 20;
hour1 = data1(:,1);
min1 = data1(:,2);
sec1 = data1(:,3);
flow1 = data1(:,4);
date1 = datenum(year1, month1, day1,hour1, min1,sec1);
and the same for the second day, and use the following script to plot them in one figure:
figure(1);
plot(date1,flow1);
datetick('x',15)
hold on
plot(date2,flow2);
datetick('x',15)
while the result is the plot of second data appears as continue of the first one as the x axis data are not exactly the same.
Thanks for your time.

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

채택된 답변

Jan
Jan 2019년 5월 13일
Simply replace the line:
date2 = datenum(year2, month2, day2, hour2, min2, sec2);
by
date2 = datenum(year1, month1, day1, hour2, min2, sec2);
Then the data will use the same day.

추가 답변 (0개)

카테고리

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