MATLAB Answers

In a matrix how to replace zero by NaN.?

743 views (last 30 days)
Safi ullah
Safi ullah on 19 Apr 2018
Commented: Safi ullah on 19 Apr 2018
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.

  0 Comments

Sign in to comment.

Accepted Answer

njj1
njj1 on 19 Apr 2018

Try this:

A(A==0) = NaN;

  1 Comment

Safi ullah
Safi ullah on 19 Apr 2018
@ njj1, thanks it works well.

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags