how to Insert cell array into a cell?

8 Ansichten (letzte 30 Tage)
Tobias Egebjerg
Tobias Egebjerg am 11 Nov. 2022
Kommentiert: Stephen23 am 11 Nov. 2022
Hey guys, i need help inserting a cell array into a cell in another cell array. My problem has the form of this:
%INPUT
A = {'one''two''three'};
B = {'four''five''six'};
B{1,1} = A{1,:}
%WANTED OUTPUT
B = {'one''two''three'},{'five'},{'six'}
I really hope someone can help

Akzeptierte Antwort

VBBV
VBBV am 11 Nov. 2022
%INPUT
A = {'one''two''three'};
B = {A,'four''five''six'};
  7 Kommentare
Tobias Egebjerg
Tobias Egebjerg am 11 Nov. 2022
@Stephen23 I ran the script and it only creates empty cell arrays.
Stephen23
Stephen23 am 11 Nov. 2022
D = 1;
C = num2str(D);
A = {'one',C, 'three'};
B = {{'one'},{'two'},{'three'}};
B{1,1} = A ;
n = 10;
for i = 1:n
D = D+1;
C = num2str(D);
A = {{'one'},{C}, {'three'}};
B{i} = {B,A};
end
B{:}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
ans = 1×2 cell array
{1×4 cell} {1×3 cell}
ans = 1×2 cell array
{1×5 cell} {1×3 cell}
ans = 1×2 cell array
{1×6 cell} {1×3 cell}
ans = 1×2 cell array
{1×7 cell} {1×3 cell}
ans = 1×2 cell array
{1×8 cell} {1×3 cell}
ans = 1×2 cell array
{1×9 cell} {1×3 cell}
B{1}
ans = 1×2 cell array
{1×3 cell} {1×3 cell}
B{1}{1}{:}
ans = 1×3 cell array
{'one'} {'1'} {'three'}
ans = 1×1 cell array
{'two'}
ans = 1×1 cell array
{'three'}
B{1}{2}{:}
ans = 1×1 cell array
{'one'}
ans = 1×1 cell array
{'2'}
ans = 1×1 cell array
{'three'}
What exactly do you mean by "lost" ?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by