Inserting NaN in particular spots of my matrix, all while "preserving" or shifting all other numbers
조회 수: 6 (최근 30일)
이전 댓글 표시
I want to insert NaN in particular spots of two different sized matrices, with the number I'm "replacing" being shifted "down". For example:
a = [1 5 NaN 4 NaN 10 3]
b = [6 1 0 3 5]
I want b to look like:
b = [6 1 NaN 0 NaN 3 5]
So essentially my NaNs are located in the same index as matrix 1, however, I want to preserve the numbers in b, by moving them down by one index in my new matrix.
Any tips?
댓글 수: 0
채택된 답변
Alfonso Nieto-Castanon
2014년 7월 16일
편집: Alfonso Nieto-Castanon
2014년 7월 16일
If I am interpreting correctly (not really sure if this is what you mean by "shifted down") this should do:
c = nan(size(a));
c(~isnan(a)) = b;
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 NaNs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!