フィルターのクリア

how to convert struct to vector?

29 ビュー (過去 30 日間)
Leila
Leila 2021 年 1 月 27 日
回答済み: Kanika Gupta 2021 年 2 月 4 日
hi every body
I have a structure that it's fields are also structures with diferent length.
how could I convert them to a vector?
  1 件のコメント
Alex Alex
Alex Alex 2021 年 1 月 27 日
struct2cell ??

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

回答 (1 件)

Kanika Gupta
Kanika Gupta 2021 年 2 月 4 日
If you requirement is to access strcuture of structures as cell arrays, try this:
% For every sub strcuture
C1 = num2cell(struct2cell(subStruct),3);
C1 = cellfun(@(c)[c{:}],C1,'uni',0);
C = num2cell(struct2cell(subStrcut2),3);
C = cellfun(@(c)[c{:}],C,'uni',0);
C1 = [C1 C]
% To create struct of struct to cell
T = cell2struct(C1,F,1) % C1 will be concatenation of C1 cells for every sub struct
T = num2cell(struct2cell(T),3);
T = cellfun(@(c)[c{:}],T,'uni',0);

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by