Plot time series of two set of data

조회 수: 13 (최근 30일)
Farshid Daryabor
Farshid Daryabor 2024년 2월 7일
댓글: Mathieu NOE 2024년 2월 8일
The attached is two set of data with different size, 'ARMOR', and 'HadGEM2', respectively. I would be grateful if someone could help me to plot the time series of these two sets of data on one frame, so that the x-axis specifies the time based on the year or year and month and the y-axis value of object 'temperature'. Thanks
  댓글 수: 1
Cris LaPierre
Cris LaPierre 2024년 2월 7일
편집: Cris LaPierre 2024년 2월 7일
Your variables are timeseries, so you should just be able to plot them.
load ARMOR_anomaly.mat
Armor
timeseries Common Properties: Name: 'unnamed' Time: [20x1 double] TimeInfo: tsdata.timemetadata Data: [20x1 double] DataInfo: tsdata.datametadata
plot(Armor)
It sounds like you are saying that time data incorporated into your time series is incorrect?
Armor.Time
ans = 20×1
0 1 2 3 4 5 6 7 8 9
There is a separate time timeseries in your mat file as well. Since Time there is also just index number, I assume we should look at Data instead.
time.Data
ans = 20×1
464196 472956 481740 490500 499260 508020 516804 525564 534324 543084
Perhaps you can help us out by explaining how you created time.Data? Or where it was captured from? Is it perhaps posixtime?
datetime(time.Data,'ConvertFrom','posixtime')
ans = 20×1 datetime array
06-Jan-1970 08:56:36 06-Jan-1970 11:22:36 06-Jan-1970 13:49:00 06-Jan-1970 16:15:00 06-Jan-1970 18:41:00 06-Jan-1970 21:07:00 06-Jan-1970 23:33:24 07-Jan-1970 01:59:24 07-Jan-1970 04:25:24 07-Jan-1970 06:51:24 07-Jan-1970 09:17:48 07-Jan-1970 11:43:48 07-Jan-1970 14:09:48 07-Jan-1970 16:35:48 07-Jan-1970 19:02:12 07-Jan-1970 21:28:12 07-Jan-1970 23:54:12 08-Jan-1970 02:20:12 08-Jan-1970 04:46:36 08-Jan-1970 07:12:36
You should probably either correct your timeseries variables so the correct time and data are in a single series, or not use the timeseries data type at all.

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

답변 (1개)

Mathieu NOE
Mathieu NOE 2024년 2월 7일
hello
I started this , but I am unsure about how the dates / time is coded in your data (as I discovered , HadGEM2 has to do with Mid-Pliocene era so this is certainly not what I have now :
load('ARMOR_anomaly.mat')
xdate1 = datetime(datevec(time.Data))
xdate1 = 20×1 datetime array
03-Dec-1270 27-Nov-1294 16-Dec-1318 10-Dec-1342 04-Dec-1366 28-Nov-1390 17-Dec-1414 11-Dec-1438 05-Dec-1462 29-Nov-1486 18-Dec-1510 12-Dec-1534 06-Dec-1558 30-Nov-1582 18-Dec-1606 12-Dec-1630 06-Dec-1654 30-Nov-1678 19-Dec-1702 13-Dec-1726
data1 = (Armor.Data);
figure(1),plot(xdate1,data1,'-*',"DatetimeTickFormat","yyyy-MM");
load('HadGEM2_anomaly.mat')
xdate2 = datetime(datevec(time.Data))
xdate2 = 28×1 datetime array
16-Jan-0137 11-Jan-0138 06-Jan-0139 01-Jan-0140 26-Dec-0140 21-Dec-0141 16-Dec-0142 11-Dec-0143 05-Dec-0144 30-Nov-0145 25-Nov-0146 20-Nov-0147 14-Nov-0148 09-Nov-0149 04-Nov-0150 30-Oct-0151 24-Oct-0152 19-Oct-0153 14-Oct-0154 09-Oct-0155 03-Oct-0156 28-Sep-0157 23-Sep-0158 18-Sep-0159 12-Sep-0160 07-Sep-0161 02-Sep-0162 29-Jul-0163
data2 = (HadGEM2.Data);
figure(2),plot(xdate2,data2,'-*',"DatetimeTickFormat","yyyy-MM");
  댓글 수: 2
Farshid Daryabor
Farshid Daryabor 2024년 2월 7일
time range supposed to be 1993 to 2021
Mathieu NOE
Mathieu NOE 2024년 2월 8일
I don't understand how your time data is formated
you can always for ce the time axis to match your range
your two data sets do have different length - do they both cover the same range , or is only the longest one covering the 1993 to 2021 range (and they would have the same time spacing ?)

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by