how to plot two figures in one figure with different axes

3 ビュー (過去 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.
  1 件のコメント
amirhossein sarfi
amirhossein sarfi 2019 年 5 月 13 日
Thank you very much. It perfectly works.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by