How can I equalize the size of all arrays in a cell array?
이전 댓글 표시
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
KL
2017년 12월 1일
simply change < to <= in the original answer
Vasudha Chandrashekar
2017년 12월 1일
per isakson
2017년 12월 1일
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
2017년 12월 1일
NARENDRA KUMAR MISHRA
2022년 6월 27일
Thank a lot. It works very well!!!!!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!