12-10-2010 08:57 AM
Attached my code. If you run the code with the default input, you will see a few NaN.
12-10-2010 09:37 AM
The calculation of IaLN_RMS results in 4.999999999999996, not 5. Set the dispaly format to show 16 significant digits. Thus the calculation of Ia_THD is the result of taking the square root of -35.527E-15 = NaN.
As others have pointed out this type of calculation can result in errors.
Lynn
12-10-2010 12:46 PM
Is there a way to limit all the numbers through out my program to 3 decimal points in my calculation?
12-10-2010 12:49 PM - edited 12-10-2010 12:51 PM
You will still potentially run into problems because decimal fractions don't necessarily have exact binary fractions. One way would be to make a small subVI that multiplies by 1000, rounds to the nearest integer, then divides by 1000 again.
Overall, you have way too much duplicate code. Why not operate on arrays?
12-10-2010 02:23 PM
Hi Alten,
How would using array cut down on duplicate code? I am using cluster, because I am using it to make my code more documented, but it maybe backfiring on me. I do have to go back to the code and clean it up though. Can you give me an example of what you mean?
Yik
12-10-2010 03:54 PM - edited 12-10-2010 04:00 PM
12-10-2010 04:34 PM
Some modifications which highlights the reduced code duplication.
/Y
12-10-2010 11:55 PM
Hi Yama,
I am using 2009. Can you re-sent code in 2009?
Yik
12-10-2010 11:57 PM
Hi Alten,
That's nice!!!! I wish I can give you 10 Kudos.
Yik