Adding elements of double arrays inside cell array below another double array inside the same cell array

1 visualización (últimos 30 días)
Hello!!!!! I have a problem on dealing with cell array. I would like to ask for some help. So, my problem is that I have on cell array. Inside this cell array, there are a lot of double arrays in each cell element. The thing is that I would like to put double arrays (inside this cell) below another double array. Here are my example in file attached. "Example.mat" contains the cell array named as "Sort". and "Solution.mat" contains solutions of double array I would like to have. Sometimes, I would like to have solution as A1 array which is the solution of adding three arrays together. Another time I may want to have solution of adding two array together as shown in A4.
Here are how A1, A2, A3 are derived.
A1=[Sort{1,1}; Sort{1,2}; Sort{1,3}];
A2=[Sort{2,1}; Sort{2,2}; Sort{2,3}];
A3=[Sort{3,1}; Sort{3,2}; Sort{3,3}];
A4=[Sort{3,1}; Sort{3,2}];
Note that this example is just a small part of my real cell arrays. The actual cell array is very huge and the difficult part is that I want to make it dynamically without doing in term of [Sort{1,1}; Sort{1,2}; .....; Sort{1,n}]; where n is the last column in cell array I would like to add double array in n cell to other array.
Thank you in advance.

Respuesta aceptada

Stephen23
Stephen23 el 23 de Abr. de 2019
Editada: Stephen23 el 23 de Abr. de 2019
Concatenating the contents of a cell array is easy using a comma-separated list:
>> A1 = cat(1,Sort{1,:})
A1 =
1 2
3 4
5 6
4 5
6 7
>> A2 = cat(1,Sort{2,:})
A2 =
10 20
30 40
50 60
40 50
60 70
>> A3 = cat(1,Sort{3,:})
A3 =
100 200
300 400
500 600
400 500
600 700
Read about comma-separated lists:

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by