LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

FFT returns NaN, no error

Solved!
Go to solution

I'm trying to plot the FFT of a number of waveforms, but I'm finding that for some the outputs simply return an array of 'NaN' in place of the magnitude, with no error indicated. Looking at the data I can't see any significant differences that might cause this; can anyone shed some light on the problem?

 

I've looked at the formula apparently used by the FFT vi in the detailed help and created my own version, and it experiences the same problem with the same datasets. Probing what's coming in, it seems to come down to labview randomly taking one of my input data values and reading it as 'NaN' - one wrong magnitude and the whole FFT comes out NaN. Why it's reading that input as NaN though is a mystery, and yet it's doing it consistently because the same plots always fail.

 

I've attached the relevant vi's to look at, any help would be appreciated.

Download All
0 Kudos
Message 1 of 6
(12,565 Views)

If you only see the problem with specific datasets it would be helpful to include one of those (and one of the working ones) if they aren't too large.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 6
(12,555 Views)

Hi Marc,

 

that big race condition (in ManualFFT) might be a problem...

 

Did you check your data for NaNs?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 6
(12,553 Views)

Hi LV_Pro, good to see I've got the pro's on board!

I included example data in the example vis - there's a constant array of waveforms that it'll process and plot each of in turn. The first two should plot fine, the third will give NaN. There's a popup between each plot, so you can click 'cancel' to stop execution and see what values were last used. I've also got the manual FFT to stop execution as soon as it generates an NaN reading. I'm afraid you'll have to be a bit patient - as it only seems to happen on some datasets I've included real data, but the manual FFT takes a while to process it. 

 

@GerdW, thanks also for helping. I've looked at the dataset, and there are indicators that trace through to check what data is going where - the waveform contains an array of doubles containing no NaN's; that passes into two nested For loops, (at least in my manual version) and it's on the innermost for loop that it goes to get the first array value and gets 'NaN' instead of the actual data.

As for the race condition in the manual version ... Other than debugging indicators the whole thing only uses a single set of inputs and outputs, so I don't see where there would be race conditions in the operation? (I did however just realise I forgot to wire up that sequence structure - that was going to be to ensure the cluster output is written to last for reading internal state values at the time it first reads NaN. Perhaps you meant that?)

0 Kudos
Message 4 of 6
(12,542 Views)
Solution
Accepted by topic author marc1uk

You were asked to see if the data included NaN and you did not do this. The last element of the third data set is NaN. I did not check the other arrays since that is something you need to do.

0 Kudos
Message 5 of 6
(12,536 Views)

Oh bugger, sorry I was convinced there were no NaNs, but it looks like it really is as straightforward as that. From the manual FFT I made it looked like it was breaking on the first iteration of the inner loop, so it appeared the loop was reading NaN for one of the first values; I should have run an array scan on the input data though.

I've found where the erroneous data was coming from & everything seems to be OK.
Thanks to all who replied.

0 Kudos
Message 6 of 6
(12,529 Views)