フィルターのクリア

Make two cell vector in one

3 ビュー (過去 30 日間)
benghenia aek
benghenia aek 2023 年 8 月 30 日
コメント済み: Image Analyst 2023 年 8 月 30 日
I have two cell arrays A and B, each of size 1x5 cells. Each cell is a row vector with same size (A{1}=B{1}=1x5 vector, A{2}=B{2}=1x5 vector...) where each cell in A is the same size of the corresponding cell in B. How can I add C=[A B]?
A = [{rand(1,5)} {rand(1,5)}];
B = [{rand(1,5)} {rand(1,5)}];
I need C=[{rand(1,10)} {rand(1,10)}]

採用された回答

Rik
Rik 2023 年 8 月 30 日
A simple loop will do:
A = {rand(1,5) , rand(1,5)};
B = {rand(1,5) , rand(1,5)};
C = cell(size(A));
for n=1:numel(C)
C{n} = [A{n} B{n}];
end
C
C = 1×2 cell array
{[0.9822 0.0522 0.1813 0.5447 0.6443 0.9655 0.6505 0.0162 0.6614 0.8564]} {[0.3507 0.2496 0.1001 0.4130 0.0183 0.3468 0.9989 0.1161 0.3744 0.0965]}
  2 件のコメント
benghenia aek
benghenia aek 2023 年 8 月 30 日
Thanks
Image Analyst
Image Analyst 2023 年 8 月 30 日
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by