# Help with Matlab. - DSP

This is a discussion on Help with Matlab. - DSP ; I have a very strange problem with Matlab, I have a vector which has some complex values for example 1.4142 + 0.0000i , all values have imaginary part equal to 0.0000i . when I take imag() or angle() of this ...

1. ## Help with Matlab.

I have a very strange problem with Matlab,

I have a vector which has some complex values for example 1.4142 +
0.0000i , all values have imaginary part equal to 0.0000i . when I
take imag() or angle() of this vector i do not get zero , instead I
get some value like 1.0e-015 * -0.1110 . If I take imag() or angle()
of the individual value ans is 0.

Why I am not getting the answer = 0 for the whole vector ???

2. ## Re: Help with Matlab.

nomee97 wrote:
> I have a very strange problem with Matlab,
>
> I have a vector which has some complex values for example 1.4142 +
> 0.0000i , all values have imaginary part equal to 0.0000i . when I
> take imag() or angle() of this vector i do not get zero , instead I
> get some value like 1.0e-015 * -0.1110 . If I take imag() or angle()
> of the individual value ans is 0.
>
> Why I am not getting the answer = 0 for the whole vector ???

Welcome to the real world. If the imaginary part of your result plotted
an inch long, how long would the real part be? If the real part plotted
a foot long, wow long would the imaginary part be?

Computers don't deal with numbers; they deal with bits. After several
operations, it is reasonable to expect total roundoff errors of two or
three bits. how much accuracy do you expect?

Jerry
--
Engineering is the art of making what you want from things you can get.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

3. ## Re: Help with Matlab.

Hello nomee97,

Maybe the formating for the vetor and the individual values is different.
I don't remember the exact command, but there's a command to print the
"full" number without rounding.
Try "lookfor format" or something like that. Switch on all digits. I'm sure
1.0e-15 is also in the individuals.

Wolfgang

"nomee97" <nomi97et@hotmail.com> schrieb im Newsbeitrag
>I have a very strange problem with Matlab,
>
> I have a vector which has some complex values for example 1.4142 +
> 0.0000i , all values have imaginary part equal to 0.0000i . when I
> take imag() or angle() of this vector i do not get zero , instead I
> get some value like 1.0e-015 * -0.1110 . If I take imag() or angle()
> of the individual value ans is 0.
>
> Why I am not getting the answer = 0 for the whole vector ???
>

4. ## Re: Help with Matlab.

On Aug 20, 3:55 pm, "Greg" <G...@nospam.ca> wrote:
> Hello nomee97,
>
> Maybe the formating for the vetor and the individual values is different.
> I don't remember the exact command, but there's a command to print the
> "full" number without rounding.
> Try "lookfor format" or something like that. Switch on all digits. I'm sure
> 1.0e-15 is also in the individuals.
>
> Wolfgang
>
> "nomee97" <nomi9...@hotmail.com> schrieb im Newsbeitragnews:1187593846.505472.265030@k79g2000hse.googlegroups.com...
>
>
>
> >I have a very strange problem with Matlab,

>
> > I have a vector which has some complex values for example 1.4142 +
> > 0.0000i , all values have imaginary part equal to 0.0000i . when I
> > take imag() or angle() of this vector i do not get zero , instead I
> > get some value like 1.0e-015 * -0.1110 . If I take imag() or angle()
> > of the individual value ans is 0.

>
> > Why I am not getting the answer = 0 for the whole vector ???- Hide quoted text -

>
> - Show quoted text -

yes I got it thanks a lot,,

The problem was exactly as you described.

5. ## Re: Help with Matlab.

On Aug 20, 10:13 am, nomee97 <nomi9...@hotmail.com> wrote:
> On Aug 20, 3:55 pm, "Greg" <G...@nospam.ca> wrote:
>
>
>
> > Hello nomee97,

>
> > Maybe the formating for the vetor and the individual values is different.
> > I don't remember the exact command, but there's a command to print the
> > "full" number without rounding.
> > Try "lookfor format" or something like that. Switch on all digits. I'm sure
> > 1.0e-15 is also in the individuals.

>
> > Wolfgang

>
> > "nomee97" <nomi9...@hotmail.com> schrieb im Newsbeitragnews:1187593846.505472.265030@k79g2000hse.googlegroups.com...

>
> > >I have a very strange problem with Matlab,

>
> > > I have a vector which has some complex values for example 1.4142 +
> > > 0.0000i , all values have imaginary part equal to 0.0000i . when I
> > > take imag() or angle() of this vector i do not get zero , instead I
> > > get some value like 1.0e-015 * -0.1110 . If I take imag() or angle()
> > > of the individual value ans is 0.

>
> > > Why I am not getting the answer = 0 for the whole vector ???- Hide quoted text -

>
> > - Show quoted text -

>
> yes I got it thanks a lot,,
>
> The problem was exactly as you described.

When matlab displays a complex number which have vastly different
exponents e.g. 5.44e15 +j*5.44e-15 then the smaller one tends to
display as zero. Matlab tends to try to find 1 exponential value which
works for all the numbers in a vector/matrix - it can't always find
one.

You can use "format long" to get more decimal places in the display
and "format short" to go back to the default.

Cheers,
Dave