Info
此问题已关闭。 请重新打开它进行编辑或回答。
Is there a way to replace a specific NaN elements by integer where isnan would not work with steps greater than 1?
1 次查看(过去 30 天)
显示 更早的评论
Hello All,
Could you please help with this problem
I have this matrix
hh=[NaN 1 2 3 4;3 5 66 NaN 6;NaN 3 4 7 NaN; 9 NaN 8 2 NaN];
and I want to replace only the NaN in some places to an integer. I have tried this hh(isnan(hh(1:2:4,1)))=1; which should replace the NaN in element (3,1) by 1 but did not work
0 个评论
回答(1 个)
Walter Roberson
2017-7-4
mask = isnan(hh(:, 1)); mask(2:2:end) = false;
hh(mask) = 1;
2 个评论
Walter Roberson
2017-7-5
isnan(hh(1:2:4,1)) is true for hh(1,1) so you have indicated that you do want hh(1,1) to be replaced.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!