Azzera filtri
Azzera filtri

Insert values of arrays in another cell array

2 visualizzazioni (ultimi 30 giorni)
I have the following problem. In the attached picture I three columns of cells. My goal is to append the 2nd and 3rd column inside the first column. So in the end I will end up with only one column and the size of all cells inside will be rows x 19 double. where the 18th column comes from my original column2 and the 19th column comes from my original column3. How can I do this?

Risposta accettata

Guillaume
Guillaume il 30 Giu 2015
Modificato: Guillaume il 30 Giu 2015
Use a loop (or arrayfun):
result = cell(size(gencostSorted_New, 1), 1);
for row = 1 : size(gencostSorted_New)
result{row} = [gencostSorted_new{row, :}];
end
Or
result = arrayfun(@(row) [gencostSorted_new{row, :}], 1:size(gencostSorted_new), 'UniformOutput', false);
The clever bit is the [gencostSorted_New{row, :}] which concatenate all the cells of a row into a matrix.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by