trimming matrix arrays arranged within cell arrays
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a cell array (CellArray) where wihtin each cell is a matrix of multiple collumns and rows of numbers.
To call each the first array of numbers, I simply write: CellArray{1}, the second CellArray{2}.
I would like to use cellfun to trim the column lengths of each array in each cell so they are all the same number of rows (for example 10 rows).
I know it should look something like this, but I don't know how to correctly define the function without involving a for-loop:
TrimmedArray = CellArray((cellfun(@CellArray{:,1:10})));
I would love some suggestions for how to implement the cellfun function better.
Until then, I am going to make do with a long and ugly for loop.
0 Commenti
Risposte (2)
madhan ravi
il 8 Lug 2020
TrimmedArray = cellfun(@(x) x(1:10,:),CellArray,'un',0);
celldisp(TrimmedArray)
0 Commenti
James Tursa
il 8 Lug 2020
It is not clear whether you want the rows or columns trimmed. Maybe one of these is what you want?
TrimmedArray = cellfun(@(x) x(:,1:10),CellArray,'uni',false);
or
TrimmedArray = cellfun(@(x) x(1:10,:),CellArray,'uni',false);
0 Commenti
Vedere anche
Categorie
Scopri di più su Structures 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!