hi, I have this matrices : u=[0;0;0;0;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN] and up=[2;4;5;3;1;7;3;41] I wanna replace nan in "u" matrix with the variants of "up" matrix please answer to my question if you can , I really need the answer immediately, thanks

 채택된 답변

Thorsten
Thorsten 2015년 11월 20일

1 개 추천

This works is you have at least N values in up, where N is the number of NaNs in u.
u=[0;0;0;0;NaN;NaN;NaN;NaN;NaN;NaN;NaN;NaN];
up=[2;4;5;3;1;7;3;41]
ind = isnan(u)
u(ind) = up(1:nnz(ind))

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 NaNs에 대해 자세히 알아보기

태그

질문:

2015년 11월 20일

댓글:

2015년 11월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by