how to put rows of a cell matrix into a cell array in matlab in matlab

You can use indexing to extract the rows of a cell matrix into a cell array in Matlab. Here's an example:

main.m
% create a 3x3 cell matrix
cell_matrix = {
    [1, 2, 3], [4, 5, 6], [7, 8, 9];
    ['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i'];
    [true, false], [pi, eps], {'hello', 'world'}
};

% extract the first and third rows into a cell array
cell_array = cell_matrix([1, 3], :);
278 chars
10 lines

The above code creates a 3x3 cell matrix called cell_matrix. The first and third rows of this matrix are then extracted using indexing and stored in the cell array cell_array.

Note that the : in the indexing expression means to select all columns. If you only want to extract certain columns, you can replace : with a vector of column indices. For example, to extract the first and third rows and the second column of cell_matrix, you can use:

main.m
cell_array = cell_matrix([1, 3], 2);
37 chars
2 lines

gistlibby LogSnag