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:
Ifft returns NaN

Subject: Ifft returns NaN

From: Annelies Geusens

Date: 19 May, 2012 09:49:21

Message: 1 of 9

Hi,

I'm having troubles with the ifft-function in matlab. It returns a vector with NaN + i NaN.
I've checked that the input doesn't contain NaN's or Inf's (nor in the real part, nor in the imaginary part). I'm using a vector of length 2048. (btw, the real part of the input is symmetric and the imaginary part is anti-symmetric). Does anyone know why it is returning NaN's?

Thanks in advance,
Annelies

Subject: Ifft returns NaN

From: Bruno Luong

Date: 19 May, 2012 15:28:30

Message: 2 of 9

"Annelies Geusens" wrote in message <jp7qb1$3a3$1@newscl01ah.mathworks.com>...
> Does anyone know why it is returning NaN's?

It should not, unless something is terribly wrong with your Matlab installation.

Bruno

Subject: Ifft returns NaN

From: Bruno Luong

Date: 19 May, 2012 16:14:22

Message: 3 of 9

"Annelies Geusens" wrote in message <jp7qb1$3a3$1@newscl01ah.mathworks.com>...

> > Does anyone know why it is returning NaN's?

Or do you perhaps name of your own variable/function IFFT?

Bruno

Subject: Ifft returns NaN

From: Annelies Geusens

Date: 19 May, 2012 16:47:13

Message: 4 of 9

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <jp8gsu$rnv$1@newscl01ah.mathworks.com>...
> "Annelies Geusens" wrote in message <jp7qb1$3a3$1@newscl01ah.mathworks.com>...
>
> > > Does anyone know why it is returning NaN's?
>
> Or do you perhaps name of your own variable/function IFFT?
>
> Bruno

Thanks for your response.
I've no own variables or function with the name ifft.
It's weird, because on some signals, the ifft outputs normal values (so then it's working well) and on some signals it outputs NaN's like I said before.
But I will try to run the code on another machine.

Annelies

Subject: Ifft returns NaN

From: Bruno Luong

Date: 19 May, 2012 16:55:24

Message: 5 of 9

Can you upload the data that causes the problem?

Bruno

Subject: Ifft returns NaN

From: TideMan

Date: 19 May, 2012 21:48:34

Message: 6 of 9

On Saturday, May 19, 2012 9:49:21 PM UTC+12, Annelies Geusens wrote:
> Hi,
>
> I'm having troubles with the ifft-function in matlab. It returns a vector with NaN + i NaN.
> I've checked that the input doesn't contain NaN's or Inf's (nor in the real part, nor in the imaginary part). I'm using a vector of length 2048. (btw, the real part of the input is symmetric and the imaginary part is anti-symmetric). Does anyone know why it is returning NaN's?
>
> Thanks in advance,
> Annelies

Almost certainly, you have NaN in your input variable. Even one NaN is enough to give NaN throughout the results.
When you say you've checked that, how exactly did you check? Show us the code.
I suspect your bug is in the NaN checking.

Subject: Ifft returns NaN

From: Annelies Geusens

Date: 19 May, 2012 22:17:17

Message: 7 of 9

TideMan <mulgor@gmail.com> wrote in message <84582e07-0880-48a6-b4e6-604ce2919da9@googlegroups.com>...
> On Saturday, May 19, 2012 9:49:21 PM UTC+12, Annelies Geusens wrote:
> > Hi,
> >
> > I'm having troubles with the ifft-function in matlab. It returns a vector with NaN + i NaN.
> > I've checked that the input doesn't contain NaN's or Inf's (nor in the real part, nor in the imaginary part). I'm using a vector of length 2048. (btw, the real part of the input is symmetric and the imaginary part is anti-symmetric). Does anyone know why it is returning NaN's?
> >
> > Thanks in advance,
> > Annelies
>
> Almost certainly, you have NaN in your input variable. Even one NaN is enough to give NaN throughout the results.
> When you say you've checked that, how exactly did you check? Show us the code.
> I suspect your bug is in the NaN checking.

I've checked NaN by taking the max and min value over the entire input vector.
It's difficult to upload the code, because it consists of multiple files working together and a whole bunch of input signals.

But it's weird. This evening suddenly it was working, an hour later Matlab crashed, so I restarted it, and now it's again the problem with the NaN's. So I think there is something wrong with my installation.

Subject: Ifft returns NaN

From: David Epstein

Date: 19 May, 2012 22:33:58

Message: 8 of 9

"Annelies Geusens" wrote in message <jp965d$jit$1@newscl01ah.mathworks.com>...
> TideMan <mulgor@gmail.com> wrote in message <84582e07-0880-48a6-
> > Almost certainly, you have NaN in your input variable. Even one NaN is enough to give NaN throughout the results.
> > When you say you've checked that, how exactly did you check? Show us the code.
> > I suspect your bug is in the NaN checking.
>
> I've checked NaN by taking the max and min value over the entire input vector.

From "help max": NaN's are ignored when computing the maximum.

And "min" will also ignore NaNs. Use "isnan" instead.

Subject: Ifft returns NaN

From: Annelies Geusens

Date: 20 May, 2012 07:52:24

Message: 9 of 9

"David Epstein" <David.Epstein.spam@remove.warwick.ac.uk> wrote in message <jp974m$mu8$1@newscl01ah.mathworks.com>...
> "Annelies Geusens" wrote in message <jp965d$jit$1@newscl01ah.mathworks.com>...
> > TideMan <mulgor@gmail.com> wrote in message <84582e07-0880-48a6-
> > > Almost certainly, you have NaN in your input variable. Even one NaN is enough to give NaN throughout the results.
> > > When you say you've checked that, how exactly did you check? Show us the code.
> > > I suspect your bug is in the NaN checking.
> >
> > I've checked NaN by taking the max and min value over the entire input vector.
>
> From "help max": NaN's are ignored when computing the maximum.
>
> And "min" will also ignore NaNs. Use "isnan" instead.


Ok, problem solved. (I had to use isnan)

Thank you for your quick responses.

Annelies

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