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:
Logical of 0/NaN!!!

Subject: Logical of 0/NaN!!!

From: Bruno Luong

Date: 6 Apr, 2010 14:21:05

Message: 1 of 7

I have this piece of code that crashes my Matlab 2010a 64 bits, Vista.

a=zeros(1,2e4);
a(1000:1000:end)=NaN;
a(logical(0./a)) = 0;

With 2007a, it throw an error of the third statement "NaN's cannot be converted to logicals."

Can someone else confirm so I can report to TMW as a bug?

Admittedly this piece of code is strange, but the crashes indicates something is not right in the built-in basic library.

Bruno

Subject: Logical of 0/NaN!!!

From: Oliver Woodford

Date: 6 Apr, 2010 14:43:06

Message: 2 of 7

"Bruno Luong" wrote:
> I have this piece of code that crashes my Matlab 2010a 64 bits, Vista.
>
> a=zeros(1,2e4);
> a(1000:1000:end)=NaN;
> a(logical(0./a)) = 0;
>
> With 2007a, it throw an error of the third statement "NaN's cannot be converted to logicals."
>
> Can someone else confirm so I can report to TMW as a bug?
>
> Admittedly this piece of code is strange, but the crashes indicates something is not right in the built-in basic library.
>
> Bruno

This also crashes my MATLAB 2010a on 32 bit Windows XP.
Oliver

Subject: Logical of 0/NaN!!!

From: Jan Simon

Date: 6 Apr, 2010 15:05:05

Message: 3 of 7

Dear Bruno!

> I have this piece of code that crashes my Matlab 2010a 64 bits, Vista.
>
> a=zeros(1,2e4);
> a(1000:1000:end)=NaN;
> a(logical(0./a)) = 0;
>
> With 2007a, it throw an error of the third statement "NaN's cannot be converted to logicals."
>
> Admittedly this piece of code is strange, but the crashes indicates something is not right in the built-in basic library.
>
> Bruno

Perhaps the level of strangeness can be reduced?
  a = zeros(1, 5);
  a(logical([0, 1, NaN, 0 / 0, 0 / NaN])) = 0
or:
  b = 0;
  b(logical(0 / b)) = 0
I do not have 2010a to test this.

In 2009a the expected error message "NaN's cannot be converted to logicals." appears, as you surely know already, Bruno.

Thanks Bruno for finding this bug! Jan

Subject: Logical of 0/NaN!!!

From: Bruno Luong

Date: 6 Apr, 2010 15:19:06

Message: 4 of 7

"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <hpfij0$91v$1@fred.mathworks.com>...

>
> Perhaps the level of strangeness can be reduced?
> a = zeros(1, 5);
> a(logical([0, 1, NaN, 0 / 0, 0 / NaN])) = 0
> or:
> b = 0;
> b(logical(0 / b)) = 0

Hi Jan and Olivier,

Both of the above still work. The crash appears with larger size like in the original code.

I have reported the bug.

Thanks,

Bruno

Subject: Logical of 0/NaN!!!

From: Matt J

Date: 6 Apr, 2010 15:32:05

Message: 5 of 7

"Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <hpfh9q$i41$1@fred.mathworks.com>...
 
> This also crashes my MATLAB 2010a on 32 bit Windows XP.
======

R2009b as well.

Subject: Logical of 0/NaN!!!

From: Matt Fig

Date: 6 Apr, 2010 15:50:05

Message: 6 of 7

Just an error in 2007b. Good find.

Subject: Logical of 0/NaN!!!

From: Yuri Geshelin

Date: 6 Apr, 2010 16:49:04

Message: 7 of 7

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hpfk5l$6gc$1@fred.mathworks.com>...
> "Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <hpfh9q$i41$1@fred.mathworks.com>...
>
> > This also crashes my MATLAB 2010a on 32 bit Windows XP.
> ======
>
> R2009b as well.

Version 7.7.0.471 (R2008b):

These 3 lines cause crash. Replacing

a(logical(0./a)) = 0;

with

i = logical(0./a); a(i) = 0;

does not initialize variable i. Hence the "Uninitialized subscript" error message.

Tags for 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