Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
detect NaN in a matrix

Subject: detect NaN in a matrix

From: pink

Date: 5 Jun, 2011 21:12:04

Message: 1 of 4

I have a code to detect NaN in a matrix, but an error could you help me provide a solution
data=
0.0010 0 0 4.2426
         0 NaN NaN NaN
    0.0020 4.2426 0 4.2426
         0 NaN NaN NaN

elseif isempty(data)|| isnan(data)
    warndlg ('Ceck Data ','warning!!!')
   else
  end

??? Operands to the || and && operators must be convertible to logical scalar
values.

Subject: detect NaN in a matrix

From: ImageAnalyst

Date: 5 Jun, 2011 21:37:10

Message: 2 of 4

if isempty(data) || any(isnan(data(:)))
uiwait(warndlg('Check your data'));
end

Subject: detect NaN in a matrix

From: Roger Stafford

Date: 5 Jun, 2011 21:40:04

Message: 3 of 4

"pink" wrote in message <isgrf4$cto$1@newscl01ah.mathworks.com>...
> .........
> elseif isempty(data)|| isnan(data)
> warndlg ('Ceck Data ','warning!!!')
> else
> end
>
> ??? Operands to the || and && operators must be convertible to logical scalar
> values.
- - - - - - - -
  You need to use | and & rather than || and && with vectors such as you have here. The latter operators are only to be used with scalar quantities. Of course, the logical results will be vectors too, so you will have to use such functions as 'any' or 'all' to use the results in 'if' statements such as you give in your example.

Roger Stafford

Subject: detect NaN in a matrix

From: pink

Date: 5 Jun, 2011 22:11:04

Message: 4 of 4

all thanks very much

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us