How to Increment matrix

10 ビュー (過去 30 日間)
Andrew Dicom
Andrew Dicom 2017 年 9 月 11 日
コメント済み: Andrew Dicom 2017 年 9 月 13 日
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 件のコメント
Andrew Dicom
Andrew Dicom 2017 年 9 月 11 日
Sorry :/ It's basically something like this e.g [15 25 01] I want to to increment it by 30 seconds for 180 times.
So the output will look like this:
15 25 01
15 25 31
15 26 01
Etc...
I know it probably sounds simple but it's one of my first time using this program...
I'm using R2012a so datetime can't really function here and I've tried installing it but it still seems not to work... Is there another way?
Thank you and sorry if it sounds like a juvenile question.
Image Analyst
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
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
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
Andrew Dicom
Andrew Dicom 2017 年 9 月 13 日
thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by