How to insert a blank column in the matrix
조회 수: 3 (최근 30일)
이전 댓글 표시
채택된 답변
dpb
2015년 7월 17일
inPos=4; % location at which to insert
Nz=1; % number of zeros to insert
x=[x(1:inPos-1) repmat(0,1,N) x(nPos:end];
In more general case of an array the subscripts will need to run over all rows using the ":" operator and the above would be the column indices. the '1' argument in repmat would then be the value of size(x,1) of course (or use zeros with appropriate size(s).
댓글 수: 0
추가 답변 (1개)
Walter Roberson
2015년 7월 17일
Numeric matrices cannot have blank columns. You can put in any constant value, including -inf, inf, and NaN, but not blank.
Cell arrays can have entries which are the empty matrix.
댓글 수: 1
dpb
2015년 7월 17일
Good point, Walter; I skimmed over the "blank" reading it as zero w/o even thinking of it...but, I guess it was good enough. :)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!