Initialize a field in all elements of a struct array
조회 수: 15 (최근 30일)
이전 댓글 표시
Hi,
I'm looking for a "one-liner" for initialization of a certain field in an existing struct array. I know that I may achieve this by calling struct(somefiledname,values), or something similar) but I want to initialize all of these additional fields for an existing array of structs, without changing the existing fields.
For example- I have a(1).field1=1; a(2).field1=2; a(3).field1=3;
and I want a one-liner which will add an additional field- "field2" to the "a" struct array (possibly- all ones, all zeros etc.).
Any such shortcut? Or the only way is to iterate through the array?
Thanks!
댓글 수: 0
채택된 답변
추가 답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!