필터 지우기
필터 지우기

How to make each matrix in a cell of equal size by adding NaN?

조회 수: 2 (최근 30일)
Antonio
Antonio 2018년 1월 19일
댓글: Antonio 2018년 1월 19일
How may I make each matrix in a cell of equal size by adding NaN? My data is a 1000x1 cell containing 'nx2' sized matrices and looks like this:
A =
[8x2 double]
[6x2 double]
[9x2 double]
[6x2 double]
[7x2 double]
...

채택된 답변

Birdman
Birdman 2018년 1월 19일
An approach:
A={rand(8,2);rand(6,2);rand(9,2);rand(6,2);rand(7,2)};
sizesRow=cellfun(@(x) size(x,1),A);
addition=max(sizesRow)-sizesRow;
for i=1:size(A,1)
A{i}(sizesRow(i)+1:sizesRow(i)+addition(i),:)=NaN;
end
  댓글 수: 3
Antonio
Antonio 2018년 1월 19일
Thank you guys. @Birdman @Jan Simon

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by