How to Increment matrix
조회 수: 8 (최근 30일)
이전 댓글 표시
Hello I am new to Matlab.
I have been trying to increment a 1 by 3 matrice (basically time in Hh:mm:Ss.sss) by 30 seconds, n number of times. What's the best way to do this?
Thank you!
댓글 수: 4
Image Analyst
2017년 9월 11일
편집: Image Analyst
2017년 9월 11일
Don't do it like that. Use official time variables instead of trying to keep track of all the parts of time yourself. It will be so much easier. See answer below for one way.
채택된 답변
KL
2017년 9월 11일
start_t = datenum('15:25:01','HH:MM:SS')
step_t = datenum('15:25:31','HH:MM:SS')-datenum('15:25:01','HH:MM:SS');
end_t = datenum('16:55:01','HH:MM:SS')
ts = start_t:step_t:end_t;
ts_dvec = datevec(ts);
댓글 수: 5
KL
2017년 9월 12일
your_folder = 'YOUR_FOLDER_PATH'; %folder where mat files are there
folderInfo = dir([your_folder '/*.mat']);
fnames = {folderInfo.name};
n = 180; %your count
for iFile=1:numel(fnames)
S = load(fullfile(your_folder,fnames{iFile}));
starttime = S.yourvarname; %must be a text in 'HH:MM:SS' format
start_t = datenum(starttime,'HH:MM:SS');
step_t = 3.47222e-4;
end_t = start_t+(step_t*n);
ts = start_t:step_t:end_t1;
%%do whatever you want
end
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!