please find the attached seasonal data, Thanks
How Can I plot a cell array against a double
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Farshid Daryabor
am 18 Jan. 2024
Kommentiert: Voss
am 18 Jan. 2024
Please find the attached file. I have a vector(1*40), double, that include years since 1982 to 2021, and monthly temperature data corresponding to each year in a cell (1*40). how can I plot a timeseries of temperature, so that the x-axis has to be specified the values of each year with the label of the corresponding year. thanks if someone answer my question.
1 Kommentar
Akzeptierte Antwort
Voss
am 18 Jan. 2024
Your monthly temperature data has two cells containing vectors of only 11 elements. There is no way to tell, with just the information given, which month's data is missing in those cases. Here I'll assume the months with missing data are at the end of the year, and append NaNs at the end of any vector whose length is less than 12.
S = load('1d_data.mat')
% make a datetime vector representing the 1st of each month for all S.years:
[YY,MM] = meshgrid(S.years,1:12);
DT = datetime(YY(:),MM(:),1);
% append NaNs to any vector in S.var that has fewer than 12 elements:
for k = 1:numel(S.var)
S.var{k}(end+1:12) = NaN;
end
% plot:
plot(DT,vertcat(S.var{:}))
6 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!