Adding rows to a matrix after every even row
조회 수: 6 (최근 30일)
이전 댓글 표시
Is there a way, without using a for loop, to add a row of nan's to a matrix after every even row of the original matrix? For example,
A = [6;2;2;1;1;0;]; %original A matrix will always have an even number of elements
becomes
A = [6;2;NaN;2;1;NaN;1;0];
My initial plane was to make a vector of NaN's having the same size as the final matrix.
temp = nan(size(A,1)/2 - 1,:);
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 5월 19일
편집: Azzi Abdelmalek
2013년 5월 19일
A = [6;2;2;1;1;0]
B=[reshape(A,2,[]);nan(1,numel(A)/2)];
B=B(:)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!