How to save values into a data structure within a loop?
이전 댓글 표시
Hello,
I have a loop in which I find data points that are within a certain hour (e.g. 0 - 1 am) for a given day, and I want to do this for multiple days in a loop.
Here is my loop:
for day = 10; % would like 10:25
for hour = 0:23;
hour
date = [num2str(day),'-Jun-2014', ' ', make_string10(hour),':']; % make_string10 adds '0' before % hour
d = strmatch(date, datestr(date524t)); % find strings in time data
dt = date524t(d); % select time values
dy = y524t(d); % select y values (depth)
dz = z524t(d); % select z values (Temperature)
d = struct; % now I want a structure to contain this organised data
end
end
I want to save values as a structure array as follows:
d.day(day).hour(hour) = dt for example % or something similar
My ultimate goal is to plot data as a function of time of day, please let me know how I can do this or whether there is an easier method. However, if there is an easier method can someone also explain how I can do this using data structure, as it will very useful for other things I am doing using MATLAB.
Thanks alot in advance!
Michael
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!