Create an array of empty durations
古いコメントを表示
Is there a way to create an array of durations similar to the way I can create an array of strings, zeroes etc. i.e.
str = strings(size, 0)
i tried something like
dur = durations(size, 0)
but that does not work.
採用された回答
その他の回答 (2 件)
Jan
2017 年 11 月 21 日
I asssume that https://www.mathworks.com/help/matlab/ref/nat.html: "Not-a-Time" does not help directly. What about:
duration(NaN(size));
1 件のコメント
Karol Ondrejkovic
2022 年 6 月 17 日
For me duration(strings(size)) works well.
Example:
duration(strings([2,3]))
Another way to create an empty array of duration objects is to use the empty function for the class.
d = duration.empty(5, 0)
2 件のコメント
Raphaël Nussbaumer
2021 年 4 月 21 日
Nice one! Much better. It would be nice to be able to do:
duration.empty(size(X))
with X another matrix od any size.
Thanks anyway!
As long as X is empty you can.
X = zeros(1, 2, 3, 4, 0);
D = duration.empty(size(X));
size(D)
An empty array in MATLAB must have the size in at least one dimension equal to 0 (as per the documentation for the isempty function) so something like this wouldn't work as the error message clearly states.
X = 1:10;
D = duration.empty(size(X))
カテゴリ
ヘルプ センター および File Exchange で Data Type Identification についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!