Looping DateNum through Cell Array
2 views (last 30 days)
Show older comments
I am trying to put this through code a loop and read in values from my cell array but I get an error saying that the matrices are different sizes. Is it possible to use datenum in cell arrays?
% cell containing all YYYY MM DD HH WDIR WSPD Data
date_cell = {nineteen_49, nineteen_50, nineteen_51, nineteen_52, nineteen_53, nineteen_54, nineteen_55, nineteen_56, nineteen_57, nineteen_58, nineteen_59, nineteen_60, nineteen_61, nineteen_62, nineteen_63, nineteen_64, nineteen_65, nineteen_66, nineteen_67, nineteen_68, nineteen_69, nineteen_70, nineteen_71, nineteen_72, nineteen_73, nineteen_74, nineteen_75, nineteen_76, nineteen_77, nineteen_78, nineteen_79, nineteen_80, nineteen_81, nineteen_82, nineteen_83, nineteen_84, nineteen_85, nineteen_86, nineteen_87, nineteen_88, nineteen_89, nineteen_90, nineteen_91, nineteen_92, nineteen_93, nineteen_94, nineteen_95, nineteen_96, nineteen_97, nineteen_98, nineteen_99, twothousand_00, twothousand_01, twothousand_02, twothousand_03, twothousand_04, twothousand_05, twothousand_06, twothousand_07, twothousand_08, twothousand_09, twothousand_10, twothousand_11, twothousand_12, twothousand_13, twothousand_14, twothousand_15, twothousand_16};
% Define N (no. of years)
N = 67;
% make a new cell which we will add the matlab dates to
d_cell = date_cell(1,:);
% delete 5 columns from this so it is now just 1 column
for k = 1:N
d_cell{k}(:,2:6) = [];
end
% make all values Nan
for k = 1:N
d_cell{k}(:,1) = nan;
end
% loop over and add the new matlab dates
for k = 1:N
d_cell{k}(:,1) = datenum([date_cell{k}(:,1:4), zeros(length(date_cell{k})),2]);
end
3 Comments
dpb
on 8 Feb 2017
Almost certainly not...see the comments in the other thread on same subject by a different name.
Answers (0)
See Also
Categories
Find more on Sparse Matrices 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!