How to plot gridded data

10 Ansichten (letzte 30 Tage)
Lemea Akara
Lemea Akara am 29 Jun. 2021
Kommentiert: Walter Roberson am 3 Jul. 2021
please help, I used the retime function to change my gridded temperature data from daily to yearly. I tried plotting the data using pcolor but got the error (color data input must be a matrix) How can I plot this data?
  6 Kommentare
Walter Roberson
Walter Roberson am 29 Jun. 2021
Your dt from above is 1 element longer than 16435. datetime('1-jan-2015')-datetime(1970,1,1) is 16436 days. You lost a day somewhere ??
Lemea Akara
Lemea Akara am 29 Jun. 2021
Ohk, it is 16436, that was a typo error. Thank you @walter, I will try the code you sent and surely give a feedback on it.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 29 Jun. 2021
dt=(datetime(1970,01,01) :datetime(2014,12,31))';
temp_data = randi(9, 16436,900);
T = timetable (dt,temp_data);
yearlytemp = retime(T, 'yearly', 'sum');
yt = yearlytemp{:,1};
p = pcolor(1:size(yt,2), yearlytemp.dt, yt); p.EdgeColor = 'none';
  8 Kommentare
Lemea Akara
Lemea Akara am 3 Jul. 2021
Thank you for all your replies @walter.
I got an error in the third line maskedyearly(BW) = nan;
The error reads; subscripting into table using one subscript is not supported.
Walter Roberson
Walter Roberson am 3 Jul. 2021
BW = poly2mask(x, y, size(yearlytemp,1), size(yearlytemp,2))
maskedyearly = yearlytemp{:,1};
maskedyearly(BW) = nan;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by