From: N S on
EDU>> b = [ (2 + 3i) (2 - 3i) 0 (-2+3i) (-2-3i) (0+3i) (0-3i)];

EDU>> complex_sign = sqrt(b.^2)./b
Warning: Divide by zero.

complex_sign =

1 1 NaN -1 -1 1 1
% Yeah, I know about the divide by zero, that's OK. what's not is result in column 7... it should be as below:
EDU>> sqrt((-3i).^2)./(-3i)
ans = -1

EDU>> complex_sign = sqrt(b(7).^2)./b(7)
complex_sign = -1

EDU>> complex_sign = sqrt(b(6:7).^2)./b(6:7)
complex_sign = 1 -1

% question is why do i get the wrong answer when I run it on anything other than the last two entries in b separately???
From: us on
"N S" <nlanger(a)vt.edu> wrote in message <hvh8o8$92r$1(a)fred.mathworks.com>...
> EDU>> b = [ (2 + 3i) (2 - 3i) 0 (-2+3i) (-2-3i) (0+3i) (0-3i)];
>
> EDU>> complex_sign = sqrt(b.^2)./b
> Warning: Divide by zero.
>
> complex_sign =
>
> 1 1 NaN -1 -1 1 1
> % Yeah, I know about the divide by zero, that's OK. what's not is result in column 7... it should be as below:
> EDU>> sqrt((-3i).^2)./(-3i)
> ans = -1
>
> EDU>> complex_sign = sqrt(b(7).^2)./b(7)
> complex_sign = -1
>
> EDU>> complex_sign = sqrt(b(6:7).^2)./b(6:7)
> complex_sign = 1 -1
>
> % question is why do i get the wrong answer when I run it on anything other than the last two entries in b separately???

this has been repaired...
r2010a, which version do you use(?)...

b=[ (2 + 3i) (2 - 3i) 0 (-2+3i) (-2-3i) (0+3i) (0-3i)];
sqrt(b.^2)./b
% ans = 1 1 NaN -1 -1 1 -1

% also, look at TMW's buglist...

http://www.mathworks.com/support/bugreports/

us
From: N S on
"us " <us(a)neurol.unizh.ch> wrote in message <hvha58$57s$1(a)fred.mathworks.com>...
> "N S" <nlanger(a)vt.edu> wrote in message <hvh8o8$92r$1(a)fred.mathworks.com>...
> > EDU>> b = [ (2 + 3i) (2 - 3i) 0 (-2+3i) (-2-3i) (0+3i) (0-3i)];
> >
> > EDU>> complex_sign = sqrt(b.^2)./b
> > Warning: Divide by zero.
> >
> > complex_sign =
> >
> > 1 1 NaN -1 -1 1 1
> > % Yeah, I know about the divide by zero, that's OK. what's not is result in column 7... it should be as below:
> > EDU>> sqrt((-3i).^2)./(-3i)
> > ans = -1
> >
> > EDU>> complex_sign = sqrt(b(7).^2)./b(7)
> > complex_sign = -1
> >
> > EDU>> complex_sign = sqrt(b(6:7).^2)./b(6:7)
> > complex_sign = 1 -1
> >
> > % question is why do i get the wrong answer when I run it on anything other than the last two entries in b separately???
>
> this has been repaired...
> r2010a, which version do you use(?)...
>
> b=[ (2 + 3i) (2 - 3i) 0 (-2+3i) (-2-3i) (0+3i) (0-3i)];
> sqrt(b.^2)./b
> % ans = 1 1 NaN -1 -1 1 -1
>
> % also, look at TMW's buglist...
>
> http://www.mathworks.com/support/bugreports/
>
> us

I have MATLAB Version 7.1.0.124 (R14) Service Pack 3
MATLAB License Number: STUDENT

definitely not r2010a :)
From: Bruno Luong on
"N S" <nlanger(a)vt.edu> wrote in message <hvh8o8$92r$1(a)fred.mathworks.com>...

> % question is why do i get the wrong answer when I run it on anything other than the last two entries in b separately???

They are not "wrong", both are correct. Thus real issue is that Mathworks never take a care to rigorously specify how SQRT would behave on complex numbers, see also this thread:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/281873

I hope they will do.

Bruno