How can I add to cell arrays like I do with normal arrays?

1 回表示 (過去 30 日間)
timmy
timmy 2023 年 3 月 7 日
コメント済み: timmy 2023 年 3 月 7 日
Hello all
Let's say I have a cell array
T=[1234567] [80] 'K100200' 'ITEM_1' [60]
with a normal array/matrix -example p=[1 2 3 ; 4 5 6] I can do p=[p ; 7 8 9] and that will enlarge the array.
How can I do the same with the cell array above? I have tried something similar and it doesn't work with cell arrays.
Any suggestions greatly appreciated.

回答 (1 件)

Adam Danz
Adam Danz 2023 年 3 月 7 日
編集済み: Adam Danz 2023 年 3 月 7 日
T = {1234,80,'matlab','12',rand(4)}
T = 1×5 cell array
{[1234]} {[80]} {'matlab'} {'12'} {4×4 double}
TT = [T,7:9]
TT = 1×6 cell array
{[1234]} {[80]} {'matlab'} {'12'} {4×4 double} {[7 8 9]}
or
T(end+1) = {7:9}
T = 1×6 cell array
{[1234]} {[80]} {'matlab'} {'12'} {4×4 double} {[7 8 9]}
  2 件のコメント
timmy
timmy 2023 年 3 月 7 日
Thank you, what if you want to enlarge on another row rather than another element in the current row?
timmy
timmy 2023 年 3 月 7 日
Nevermind, I figured it out.
Thank you for the answer!!!

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by