Monthly means for 5 year temp time series, infinite end date
1 view (last 30 days)
Show older comments
opts = spreadsheetImportOptions("NumVariables", 17);
% Specify sheet and range
opts.Sheet = "OI-Chl SizeFrac Export (DZ";
opts.DataRange = "A2:Q1116";
% Specify column names and types
opts.VariableNames = ["Event_No", "DATEPST", "Lat", "Lon", "TChla", "Chla3um", "Chla3um1", "Chla3um2", "Sample_Temp", "Sea_Surface_Temp", "Bottom_Depth", "Sample_Depth", "Cast_Time", "WC_Program", "Num_Students", "WC_SchoolParticipants", "FA_SchoolParticipants"];
opts.VariableTypes = ["double", "datetime", "double", "double", "double", "double", "double", "double", "double", "double", "double", "double", "categorical", "categorical", "double", "categorical", "categorical"];
% Specify variable properties
opts = setvaropts(opts, ["Cast_Time", "WC_Program", "WC_SchoolParticipants", "FA_SchoolParticipants"], "EmptyFieldRule", "auto");
opts = setvaropts(opts, "DATEPST", "DatetimeFormat", "dd-MMM-yyyy");
% Import the data
OIChlSizeFracExportDatazoo = readtable("C:\Users\SD\Desktop\MATLAB projects\OI\OI-Chl SizeFrac Export (DZ).xls", opts, "UseExcel", false);
% extract date, total chla, 3µm chla, 1 to 3 µm chla, > 3 µm chla
date = OIChlSizeFracExportDZ.DATEPST; % date sampled
sampletemp = OIChlSizeFracExportDZ.Sample_Temp; % deg C
x0=10;
y0=10;
width=1100;
height=420;
set(gcf,'position',[x0,y0,width,height])
clf % I have other plots using the same variables from above
tstart_1 = datetime(2006,01,1);
tend_1 = datetime(2006,12,31);
tstart_2 = datetime(2014,01,1);
tend_2 = datetime(2018,12,31);
tstart_3 = datetime(2019,01,1);
tend_3 = datetime(2022,12,31); % would like to make this infinite so new data uploaded is taken into account
plot(date,sampletemp,"color","[0 0.4470 0.7410]-","LineWidth",1)
xlim([tstart_1 tend_1])
%hold on
%plot(date,sampletemp,"color","[0.6350 0.0780 0.1840]-","LineWidth",1)
%xlim([tstart_2 tend_2])
%hold on
%plot(date,sampletemp,"color","[0.4940 0.1840 0.5560]-","LineWidth",1)
%xlim([tstart_3 tend_3])
title('Monthly Means')
xlabel('Date (Months)')
ylabel('Temperature (^oC)')
legend('2006 - 2013','2014 - 2018','2018 - 2022','Orientation','vertical',"Location","eastoutside")
ylim([14 22])
datetick('x','mmm','keeplimits','keepticks')
%How to take the sampletemp and turn it into a mean value for a 4 or 5 year period. missing values NAN
%tend_3 - create a infinite end date would this be something like tend_3 = datetime(:);
%Thank you for any assistance,
%Shonna
2 Comments
Ganesh
on 1 Jul 2022
This comment is regarding the tend_3 variable. Instead of tryiing to make it infinite, you could consider making it the current date, so at the time of running, the new data generated to the current point would be taken into account.
If Infinite is what you are looking for, then a workaround for that would be to set a random date, at a far future.
Answers (0)
See Also
Categories
Find more on Preprocessing Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!