LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I replace 0 with NaN in an array?

I have text file with XYZ data from an interferometer.  The interferometer data is incomplete.  That is, some of the Z values in the text file are recorded at "No Data".  The "Read From Spreadsheet File.vi" reads the value "No Data" as "0 0".  I've written a vi that translates this text file into a 3D image, but I would like to have an image in which no data is displayed on the 3D Surface indicator on my front panel if there actually is no Z-data.  Is there a NaN constant that I can use in place of the number "0"?
0 Kudos
Message 1 of 5
(5,258 Views)
cappy18
 
Simply type NaN into the numeric constant.  This also works for Inf and -Inf.
 
 
MDDave
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
Message 2 of 5
(5,248 Views)

Thanks MDDave,

When reading back the file, it will interpret NaN accordingly.  I made a small test file to illustrate.  You'll see missing points (or broken line in the example).

The data is: 0.592840 0.932214 NaN 0.443935 0.842214 NaN NaN 0.365292 0.837349 (seperated by Tab in the file).

As expected, the missing points are 2, 5 & 6.

 

Message Edited by JoeLabView on 06-27-2007 12:50 PM

Message 3 of 5
(5,218 Views)

Can you give an example of your actual file. I assume you want to keep the "real" zeroes, if any exist in the data.

What does "no data" mean?

  • Is there simply a blank string between delimiters?
  • Is there a string with the words "no data" between delimiters?
  • ...?

In newer versions of LabVIEW, you can use "read from spreadsheet file" To read a 2D array of strings via a polymorphic selector. Now you can just loop over the elements, look for the special tags, and either scan the number or output NaN as needed.

(Too bad we need to abuse NaN for this, which has a slightly different special meaning. The old SAS system had a special value for "missing" ;))

Message Edited by altenbach on 06-27-2007 12:31 PM

Message 4 of 5
(5,192 Views)


@altenbach wrote:

(Too bad we need to abuse NaN for this, which has a slightly different special meaning. The old SAS system had a special value for "missing" ;))


Good ol' days...

I had never experimented with reading a file that had NaN and even sending NaN to a graph..  I was actually impressed with the outcome.  Strange graph mind you...   

0 Kudos
Message 5 of 5
(5,184 Views)