LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I am doing some calculation by using Labview, but the calculating result is always shown as"NaN". Does anyone know what does it mean?

I am doing some calculation by using Labview, but the calculating result is always shown as"NaN". Does anyone know what does it mean? The following is the program and the data I use
Download All
0 Kudos
Message 1 of 5
(3,484 Views)
NaN means "Not a number" and is the result when you do a math operation with undefined output like 0/0. Run your diagram in debug mode( light bulb on) and you'll see which node result as NaN. Once an operation yields NaN, all folowing operation will also result as NaN.


LabVIEW, C'est LabVIEW

Message 2 of 5
(3,484 Views)
You are dividing by 0 in the formula node on the upper left-hand corner of your diagram which has inputs of Q and W0. In LabView, dividing by 0 yields Not-A-Number (NaN). Q is 0 because you're incorrectly processing the array.
1. Goto the lower left-hand corner of your diagram.
2. Delete the Array Subset function.
3. Wire the output of Spreadsheet String to Array to the input of Index Array.
4. The Index Array function has two index terminals when wired to a 2D array (which is the default output of Spreadsheet String to Array). The top index terminal is the row index, the bottom index terminal is the column index. Your data is one column wide so you want to extract a column, not a row. Delete the wire from the numeric constant to the top index terminal of Index Array and wire it to the bottom index terminal.
5. LabView arrays (like C arrays) start at index 0.
5.1 Change the numeric constant =1 (wired to the index input of Index Array) to a value of 0.
5.2 I'd strongly recommend that you delete the formula node where you're trying to find the index of the array max and just use the LabView function Array Max & Min (which we discussed in response to an earlier question). If you want to use the formula node, then change for (i=1; i<202; i++) to for (i=0; i<201; i++).
If you correct the for loop problem in that first formula node, you'll still end up dividing by 0 because then the x otuput of your formula node will be equal to the max index output of the Array Max and Min function. Substracting two equal numbers yields 0 so you'll still be dividing by 0.
What are you trying to do when you subtract two indices?
If you want to keep that formula node, I suggest using the LabView function Array Size before the formula node and adding a new input to the formula node and wiring the array size to that. Use the array size input in your for loop. You have other hard-coded occurances of 201 you'll need to change also.
If your data will always be 201 entries, you should at least verify that the file had 201 numbers.
Message 4 of 5
(3,484 Views)
Jean-Pierre was specifically talking about Highlight Execution. On the diagram, click on the light-bulb on the toolbar, then run the VI and watch the values flow.
But there are a host of other useful debugging techiques. Review the Debugging Techniques topic in the LabView Help.
From any LabView window, goto Help >> VI, Function, & How-To Help >> Search, then enter DEBUGGING TECHNIQUES in the box labeled Type a keyword to find, then click List Topics, then double-click DEBUGGING TECHNIQUES.
0 Kudos
Message 5 of 5
(3,484 Views)