필터 지우기
필터 지우기

How to insert a columns of NaNs in between a matrix at multiple places

조회 수: 3 (최근 30일)
I have a matrix of 1440X4792 and I want to insert few columns (lets say 1277) of NaNs at different positions say (column positions : 1,3,6,99,100...)
Finally, my matrix will become 1440X6069 in which 1277 columns are NaN columns which we have inserted, rest of the 4792 columns remain same.

채택된 답변

madhan ravi
madhan ravi 2020년 6월 12일
편집: madhan ravi 2020년 6월 12일
[m, n] = size(matrix);
Wanted = nan(m, n + numel(col_pos));
Wanted(:,setdiff(1:size(Wanted,2),col_pos)) = matrix
  댓글 수: 1
Mohammed Yousuf
Mohammed Yousuf 2020년 6월 12일
This error is to be seen
Unable to perform assignment because the size of the left side is 1440-by-4889 and
the size of the right side is 1440-by-4792.

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

추가 답변 (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