09-19-2012 06:26 AM
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.
Solved! Go to Solution.
09-19-2012 07:33 AM
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.
09-19-2012 07:36 AM
09-19-2012 08:31 AM - edited 09-19-2012 08:32 AM
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?)
09-19-2012 09:14 AM
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.
09-19-2012 10:22 AM
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.