フィルターのクリア

how convert field struct in cellarray

14 ビュー (過去 30 日間)
aldo
aldo 2023 年 7 月 12 日
コメント済み: Star Strider 2023 年 7 月 13 日
hi, Rank_DisplayIdxsis is a field of struct
i want to convert it in cellarray
i try it:
fields = getfield(Sis,'Rank_DisplayIdxSis') (Sis is a struct)
but i see only 1 element and not all

採用された回答

Star Strider
Star Strider 2023 年 7 月 12 日
See if the struct2cell function will do what you want.
  11 件のコメント
aldo
aldo 2023 年 7 月 13 日
thank ok!!
Star Strider
Star Strider 2023 年 7 月 13 日
As always, my pleasure!

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

その他の回答 (1 件)

Divyajyoti Nayak
Divyajyoti Nayak 2023 年 7 月 12 日
Rank_DisplayIdxsis is already a cell array. When cell arrays are used as a value for struct field, then an array of structs are formed with length of the cell array. Here's the documentation for that:
Structure array - MATLAB - MathWorks India, check out the second description.
If you want to get the array and covert it to cell array, first you'll have to change Rank_DisplayIdxsis to an array of strings.
{'a','b','c'} %Cell Array
["a" "b" "c"] %Array of Strings
The double quotes are important, otherwise the strings will get concatenated.
You can then use getfield or Sis.Rank_DIsplayIdxsis to get the string array and convert it into cell array using cellstr()
  1 件のコメント
aldo
aldo 2023 年 7 月 12 日
"you'll have to change Rank_DisplayIdxsis to an array of strings"
How can do it?
i try it but is not correct
[Sis.Rank_DisplayIdxSis]

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by