How to split cell array made by matrix?

2 ビュー (過去 30 日間)
Giuseppe Marino
Giuseppe Marino 2021 年 5 月 14 日
コメント済み: Giuseppe Marino 2021 年 5 月 14 日
Hi everyone, i have a cell array made by n matrix ('n' is an input from the user).Every matrix is 3x3. I need to split this cell array in two halfs, how can i do it? I have tried in this way
num=1:1:N_ply;
lx = (length(num));
half = ceil(lx/2);
Q1 = Qk{num(1:half)}
where N_ply=8, and Qk is the cell array
  2 件のコメント
Adam Danz
Adam Danz 2021 年 5 月 14 日
編集済み: Adam Danz 2021 年 5 月 14 日
Since a 3x3 matrix cannot be split into equal halves by columns or rows you'll need to provide more information. Are you describing triangular halves?
Giuseppe Marino
Giuseppe Marino 2021 年 5 月 14 日
編集済み: Giuseppe Marino 2021 年 5 月 14 日
My Qk is an 1*8 cell, where every cell is a 3x3 matrix. But the number 8 could change, it could be 10,12, 6 or every even number. If you need more info, please tell me.

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

採用された回答

Adam Danz
Adam Danz 2021 年 5 月 14 日
% c is a 1xn cell array where n is an even number
n = numel(c);
c1 = c(1:n/2);
c2 = c(n/2+1:end);
  1 件のコメント
Giuseppe Marino
Giuseppe Marino 2021 年 5 月 14 日
Thank you! I really appreciate it,I was making a mountain out of a molehill!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by