01-25-2022 09:03 AM
I have a camera program in which I use many IMAQ functions. By the error out output of these functions, if Status is set to False, the measurement run without error. In this case, the program displays the measured value. However, in the event of an error, I would like the program to return a NaN value.
I can generate Nan value in two ways: "zero divided by zero" or "square root of -1".
In the former case, the program works well and displays a "NaN" value. In the latter case, the program always returns 0 value. Why doesn't this case work?
01-25-2022 09:12 AM - edited 01-25-2022 09:15 AM
You can just type "nan" (case insensitive) into a DBL constant/control.
(It would help to see some simplified code, especially the non-working case. For example sqrt(-1) is NOT NaN if the input is complex)
01-25-2022 09:13 AM - edited 01-25-2022 09:17 AM
Hi sziszkont,
@sziszkont wrote:
However, in the event of an error, I would like the program to return a NaN value.
I can generate Nan value in two ways: "zero divided by zero" or "square root of -1".
In the former case, the program works well and displays a "NaN" value. In the latter case, the program always returns 0 value. Why doesn't this case work?
Well, there is (atleast) a 3rd way: simply use a "NaN" float numeric constant!
Why do you need a (quite senseless) calculation to create a NaN value?
It seems you doing something wrong when calculating sqrt(-1):
01-25-2022 10:54 AM
Could you help me with what could be wrong?
01-25-2022 10:55 AM
@sziszkont wrote:
I have a camera program in which I use many IMAQ functions. By the error out output of these functions, if Status is set to False, the measurement run without error. In this case, the program displays the measured value. However, in the event of an error, I would like the program to return a NaN value.
I can generate Nan value in two ways: "zero divided by zero" or "square root of -1".
In the former case, the program works well and displays a "NaN" value. In the latter case, the program always returns 0 value. Why doesn't this case work?
Note that while "zero divided by zero" is always not a number, "square root of -1" may or may not be a number depending on the type of numeric representation.
01-25-2022 11:08 AM
We can't debug a picture.
Also... it looks like your -1 isn't wired to the Sqrt function?
Also also, get rid of the sqrt function altogether, and type "nan" into the inside of the orange box. You've got it typed into the label of the orange box.
01-25-2022 01:11 PM
Hi sziszkont,
@sziszkont wrote:
Could you help me with what could be wrong?
01-25-2022 01:48 PM
@GerdW wrote:
- missing wire at "-1" to sqrt function
Something has to be wired to the input of the Square Root function since it is required.
01-27-2022 03:14 AM
It is -1 wired to the Sqrt function, only not shown in the picture.
This has been a well-functioning program for years, but now I ran into this bug that returns 0 instead of NaN. I'm looking for an explanation for this. If I use 0/0, the error is solved, but why?
01-27-2022 03:37 AM - edited 01-27-2022 03:42 AM
You have been told already that pictures can NOT be debugged. So post your actual code if you want us to help you further than this!
And no we do not ask you to post your company top secret VI that spans 20 screens across. We would actually appreciate it if you can create a small test VI that shows the effect that you claim you see. In many cases while creating that test VI you will often already see yourself where the real problem is!