Formating all values of a structure field

2 ビュー (過去 30 日間)
Gabriel Stanley
Gabriel Stanley 2021 年 6 月 10 日
コメント済み: Gabriel Stanley 2021 年 6 月 10 日
Is there a syntax for applying a format to all vlues of a given field in a structure array(without a loop)? E.g. I have a structure array with multiple fields, and 1 field has values which are all Datetimes. While I can format individual value.field pairs, I have not stumbled onto a syntax for applying that formatting to all values in that field without looping though the structure.
MyStruct(N).DateTimeField.Format = %preferred format
works, but my attempted expansions throw faults:
MyStruct.DateTimeField.Format = %preferred format
Fault: "Scalar structure required for this assingment"
MyStruct(:).DateTimeField.Format = %preferred format
Fault: "Expected one output from a curly braces or dot indexing expression, but there were [number of Values] results."
  1 件のコメント
Jan
Jan 2021 年 6 月 10 日
Whenever you mention an error in the forum, share the message with the readers. Some reader can guess, what the message is, but you do have this important information on the screen already.

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

採用された回答

Jan
Jan 2021 年 6 月 10 日
No, you cannot access nested fields of a struct array in Matlab directly. You need a loop.
  1 件のコメント
Gabriel Stanley
Gabriel Stanley 2021 年 6 月 10 日
Dang, alright then. Thanks.

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

その他の回答 (0 件)

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by