# How can I make each cell array consistent in size?

1 visualizzazione (ultimi 30 giorni)
Farshid Daryabor il 6 Mar 2020
I'm really grateful for anyone telling me how to make the all double arrays in cell equal in zise (please find attached). For instance, I want to the all double in cell with the size 1715*11. The following code doesn'y work.
>> N = cellfun(@(x) length(squeeze(x(:,1))) , P); M = max(N);
>> N1 = cellfun(@(x) length(squeeze(x(1,:))) , P); M1 = max(N1);
>> newP = cellfun(@(x) [x, zeros( size(x, 1), M1-size(x, 2) ); zeros( M-size(x, 1), M1 )], P, 'uni' , 0);
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

Alex Mcaulley il 6 Mar 2020
N = max(cellfun('size',P,1));
M = max(cellfun('size',P,2));
newP = cellfun(@(x) [x, zeros(size(x, 1), M-size(x, 2)); zeros(N-size(x, 1), M)], P, 'uni' , 0);
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Farshid Daryabor il 6 Mar 2020
Thanks Alex

Accedi per commentare.

### Categorie

Scopri di più su Data Types 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