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

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

 採用された回答

Kazuya
Kazuya 2018 年 10 月 16 日
編集済み: Kazuya 2018 年 10 月 16 日

0 投票

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange日付と時刻 についてさらに検索

製品

リリース

R2018a

質問済み:

2018 年 10 月 16 日

編集済み:

2018 年 10 月 16 日

Community Treasure Hunt

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

Start Hunting!