Filter löschen
Filter löschen

Insert values of arrays in another cell array

2 Ansichten (letzte 30 Tage)
Eli Dim
Eli Dim am 30 Jun. 2015
Kommentiert: Eli Dim am 30 Jun. 2015
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?

Akzeptierte Antwort

Guillaume
Guillaume am 30 Jun. 2015
Bearbeitet: Guillaume am 30 Jun. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by