Convert zeros to NAN
4 次查看(过去 30 天)
显示 更早的评论
I have a matrix (N rows and M columns). It consists of integer values. I want to convert all the zero values from rows 1:N and columns 3:M to NaN. Is there any way to do so.
Thanks, Nancy
0 个评论
采纳的回答
Sean de Wolski
2011-6-14
One of many ways
idx = ~A;
idx(:,1:2) = false;
A(idx) = nan;
3 个评论
Sean de Wolski
2011-6-14
Yes. It sets any value that was a zero value (the ~ (not) command) in the first definition to be false so that it doesn't show up in the nan assignment.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!