In a matrix how to replace zero by NaN.?
258 次查看(过去 30 天)
显示 更早的评论
Hi every one, I have a matrix A=1×180. All values of matrix A are either zeros or negative numbers. I need to replace all the zeros by NaN, noted that zeros are also randomly distributed in matrix A. I have tried for loop but do not get the desired result. Any guidance will be appreciated thanks.
1 个评论
拓郎 下山
2021-5-3
I have the same problem.
I change 0 value to NaN value in nifti file of int16.
I try "V(V==0) = NaN;"
But, it doesn't work. Could you give me the answer?
Thank you for reading.
采纳的回答
njj1
2018-4-19
Try this:
A(A==0) = NaN;
4 个评论
laith awwad
2021-4-21
HOW TO NAME THE VARIABLE BECAUSE IF I RIGHT FOR EXAMPLE e = A(A==0) = NaN; GIVES ME AN ERROR
Steven Lord
2021-4-21
If you want to keep the original array around, make a copy of it then replace the values in that copy.
A = randperm(10)
B = A;
B(B > 7) = NaN
[A; B] % Use both the original vector (A) and the modified one (B)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!