datetime型の配列を宣言する方法

非常に初歩的な質問ですみません、 datetime型の配列はどのように宣言するのでしょうか?
for n=1:5
dt(n) = datetime('now'); % 「事前割り当てを検討してください」と警告が出る
end
例えば上記のdtは、datetime型5個分の領域を事前に宣言したいのですが、 zerosやcellでの宣言はエラーになります。

 Accepted Answer

Kazuya
Kazuya on 16 Oct 2018
Edited: Kazuya on 16 Oct 2018

0 votes

NaT がその用途に使えますが、、事前割り当てという感じではないですね・・。
dt = NaT(5,1);
for n=1:5
dt(n) = datetime('now'); % 「事前割り当てを検討してください」と警告は出ない
end

More Answers (0)

Categories

Products

Release

R2018a

Asked:

on 16 Oct 2018

Edited:

on 16 Oct 2018

Community Treasure Hunt

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

Start Hunting!