How can I make multiple cell array sizes the same

조회 수: 3 (최근 30일)
Kafayat Olayinka
Kafayat Olayinka 2019년 2월 9일
댓글: madhan ravi 2019년 2월 15일
I'm working with a cell array,time which has 1by4 cell. i.e time= 1 by 4 cell arrays. Each cell has differnt sizes. i.e
time{1,1}=2800 by 1
time{1,2}=1800 by 1
time{1,3}= 3099 by 1
time{1,4}= 2872 by 1
How can I make all time {1,i} size the same. i.e
time{1,i}= 3099 by 1
  댓글 수: 2
madhan ravi
madhan ravi 2019년 2월 9일
Do you want to pad with trailing zeros?

댓글을 달려면 로그인하십시오.

채택된 답변

madhan ravi
madhan ravi 2019년 2월 9일
A=max(cellfun(@length,time));
Result=cellfun(@(x) [x;zeros(A-numel(x),1)] ,time ,'un',0)
  댓글 수: 4
Kafayat Olayinka
Kafayat Olayinka 2019년 2월 14일
what if I want
b{1,1}=667 by 2800 (where b is a height by time array)
b{2,1}=667 by 1800
b{3,1}= 667 by 3099
b{4,1}= 667 by 2872
How can I make all b {i,1} size the same. i.e
b{i,1}= 667 by 3099
madhan ravi
madhan ravi 2019년 2월 15일
A=max(cellfun(@(x)size(x,2),b));
Result=cellfun(@(x) [x zeros(size(x,1),A-size(x,2),1)] ,b ,'un',0)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by