08-30-2011 09:02 AM
Hello
I had a code done by my colleague who is not working with us anymore. In an array 8 columns and programmatically generated no. of rows all values initialize as NaN values. I have never come across NaN values before.
From research I gather it is not a number but it really isn't making much sense to me. Why the cells in array are written as NaN? What is the significance of NaN? Can I leave the cells empty and not showing NaN in it?
Kind Regards
Austin
Solved! Go to Solution.
08-30-2011 09:10 AM
A NaN result is generally caused by a divide by zero.
NaN is sometimes used to initialize data to "flag" the software that a value hasn't been updated or that an error has occurred.
08-30-2011 09:11 AM - edited 08-30-2011 09:13 AM
Hi Austin,
as long as it is an array of floating point numbers you cannot make empty "cells".
NaN is a standard floating point number, the same goes for +/-Inf. It's part of the standard!
Why the cells in array are written as NaN?
Either you initialize the array with NaNs or you compute the array content with NaN as result of that computation...
08-30-2011 09:15 AM
"Not a Number" in this context was probably used by your predecessor as the numeric equivalent of "empty" (we could call it "Not a known number").
NaN is typically used as a placeholder to indicate that no value is known for the given cell. Empty is not an option for numeric values, and using e.g.. 0 to indicate that the value has not been set might not be possible either because zero might just as well be a valid value for a filled cell.
08-30-2011 09:17 AM
NaN can have some useful purposes. If you have a missing data point in the middle of a waveform graph, NaN means that datapoint doesn't get plotted.
08-30-2011 09:20 AM
Ok. Yes I understand now the significance. So If I am creating an array in future and I want to set few rows to NaN values. How do I do it. Is there a Constant called NaN?
08-30-2011 09:24 AM
Hi Austin,
for the constant you can use the standard numeric constant (set to any floating point format) and type "NaN" into it.
As NaN is a number you can type it into numeric inputs... (The same applies to +Inf and -Inf, they are standard numbers too!)
08-30-2011 09:29 AM
@GerdW wrote:
...
As NaN is a number :smileywink...
Reading in expanded form "As Not a Number is a number" hurts a little every time I read it.
Ben
08-30-2011 09:30 AM
Hi Austin
Your initialized array is filled up by value used for initialization by Initialization Array function.
See attached picture:
08-30-2011 09:31 AM
No NaN constant currently is on the palettes. It has been discussed in the Idea exchange. If you like the idea, go to the idea exchange and give it a kudo.. Ideas with more kudos have a better chance of being incorporated into a future verson of LV.
Just drop a numeric constant on the block diagram and type "NaN" - actually it does not care about case so "nan" works also.
Lynn