Cell Array Transform to Matrix as same sizes?

2 views (last 30 days)
I have a cell array like;
How can i transform it like matrix as same sizes?
There is any function for this?
  2 Comments
Rik
Rik on 20 Apr 2021
What do you mean? What size and type do you want your output to be?
delil codes
delil codes on 20 Apr 2021
eg: 2x3 cell;
6x6 sym 6x18 sym 6x12 sym
6x6 sym 6x18 sym 6x12 sym
to
12x36 matrix
i did it :)
lineStart = 1;
[lines,columns] = size(rectangularCell);
for i = 1:lines
columnStart =1;
for j = 1:columns
[xSizes, ySizes] = size(rectangularCell{i,j});
rectangularMatrix...
(lineStart:lineStart+xSizes-1,columnStart:columnStart+ySizes-1) ...
= rectangularCell{i,j};
columnStart = columnStart + ySizes;
end
lineStart = lineStart + xSizes;
end

Sign in to comment.

Answers (1)

delil codes
delil codes on 20 Apr 2021
Thx guys i did it, you can use this for rectangular cells to rectangular matrix. If your cell have cells lıke;
eg: 2x3 cell;
6x6 sym 6x18 sym 6x12 sym
6x6 sym 6x18 sym 6x12 sym
to
12x36 matrix
lineStart = 1;
[lines,columns] = size(rectangularCell);
for i = 1:lines
columnStart =1;
for j = 1:columns
[xSizes, ySizes] = size(rectangularCell{i,j});
rectangularMatrix...
(lineStart:lineStart+xSizes-1,columnStart:columnStart+ySizes-1) ...
= rectangularCell{i,j};
columnStart = columnStart + ySizes;
end
lineStart = lineStart + xSizes;
end

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!