How can I equalize the size of all arrays in a cell array?
Mostra commenti meno recenti
This is my cell array:
Q_Vic1 =
[29x1 double] [28x1 double] [28x1 double] [28x1 double] [28x1 double] [28x1 double] [28x1 double] [28x1 double] [28x1 double] [28x1 double] [29x1 double]
I need to equalize all arrays to size of [29x1]-max array size.
I tried this code(found from Matlab Answers,the one suggested by Laura Proctor ):
I get same length but different size!:
Q_Vic1 =
[29x1 double] [1x29 double] [1x29 double] [1x29 double] [1x29 double] [1x29 double] [1x29 double] [1x29 double] [1x29 double] [1x29 double] [29x1 double]
I tried the same kind of code with size and cellfun and its still not working.I know in order to convert the cell to matrix the arrays must be of same size. Any suggestions?I would really appreciate general purpose codes,rather than taking transpose of the specific arrays:I would be using the same code for different signals(inputs). Ultimately,I need to store all the arrays in different matrices(arrays,not in cell) and process these signals further. It is difficult to access them(the array) when they are in a cell. If there is an alternate method of storing the arrays in individual normal arrays,I would welcome that too.
5 Commenti
KL
il 1 Dic 2017
simply change < to <= in the original answer
Vasudha Chandrashekar
il 1 Dic 2017
per isakson
il 1 Dic 2017
Study this
Q = { [1:10]',[1:12]',[1:5]'}
len = max( cellfun(@length, Q ) )
Q2 = cellfun( @(v) padarray(v,[len-length(v),0],nan,'post'), Q, 'uni',false )
which outputs
Q =
[10x1 double] [12x1 double] [5x1 double]
len =
12
Q2 =
[12x1 double] [12x1 double] [12x1 double]
>>
padarray is a function in the Image Toolbox
Vasudha Chandrashekar
il 1 Dic 2017
NARENDRA KUMAR MISHRA
il 27 Giu 2022
Thank a lot. It works very well!!!!!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Multirate Signal Processing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!