how to plot two figures in one figure with different axes

2 次查看(过去 30 天)
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 中查找有关 Dates and Time 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by