From: Wendy on 9 Apr 2010 07:23 Hi all, I am a very simple question, but I am not sure what function that I shall use. I have a matrix as follows, a = NaN 4 NaN 3 2 1 How can I count the number of 'NaN' in the matrix? Can I change the 'NaN' to zeros at once? I tried to a(a==NaN)=0, but it does not work. Thank you, Wendy
From: Wendy on 9 Apr 2010 07:48 sorry, solved. Wendy "Wendy " <wlq121(a)gmail.com> wrote in message <hpn2n8$17b$1(a)fred.mathworks.com>... > Hi all, > > I am a very simple question, but I am not sure what function that I shall use. I have a matrix as follows, > > a = > > NaN 4 NaN > 3 2 1 > > How can I count the number of 'NaN' in the matrix? Can I change the 'NaN' to zeros at once? I tried to a(a==NaN)=0, but it does not work. > > Thank you, > Wendy
From: Wolfgang Schwanghart on 9 Apr 2010 07:53 Wendy, "equal to" doesn't work for nan. Look at the function isnan. I = isnan(a); % nr of nans nnz(I) % replace nans with zeros a(I) = 0; Best regards, Wolfgang "Wendy " <wlq121(a)gmail.com> wrote in message <hpn2n8$17b$1(a)fred.mathworks.com>... > Hi all, > > I am a very simple question, but I am not sure what function that I shall use. I have a matrix as follows, > > a = > > NaN 4 NaN > 3 2 1 > > How can I count the number of 'NaN' in the matrix? Can I change the 'NaN' to zeros at once? I tried to a(a==NaN)=0, but it does not work. > > Thank you, > Wendy
|
Pages: 1 Prev: fitting a contour with a quadrangle Next: Plotting failure envelope |