How to concatenate the elements of the structure?

19 ビュー (過去 30 日間)
M
M 2023 年 11 月 22 日
コメント済み: Stephen23 2023 年 11 月 22 日
If there is a structure with size 1*12, each element is 3D with size 120*12*N , How can I concatenate the elements of this structure?

採用された回答

Stephen23
Stephen23 2023 年 11 月 22 日
  2 件のコメント
M
M 2023 年 11 月 22 日
編集済み: M 2023 年 11 月 22 日
@Stephen23 Thanks, What about concatenation the elements of cell array 1*12 not structured with elements with size 120*12*N?
I tried cat but it gave me error
Dimensions of arrays being concatenated are not consistent.
Stephen23
Stephen23 2023 年 11 月 22 日
"What about concatenation the elements of cell array 1*12 not structured with elements with size 120*12*N? "
Then use the cell array syntax shown in the tutorial. For example:
C = {rand(120,12,3), rand(120,12,5), rand(120,12,2), rand(120,12,1), rand(120,12,0), rand(120,12,4)};
A = cat(3,C{:});
size(A)
ans = 1×3
120 12 15
"I tried cat but it gave me error Dimensions of arrays being concatenated are not consistent."
Then the dimensions of one or more of the arrays are not what you explained in your question.
Lets try it right now:
S = struct('F',C)
A = cat(3,S.F);
size(A)
ans = 1×3
120 12 15

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

その他の回答 (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