LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Round up to nearest decimal point

Hi,

 

I want to round up the previous phase values in my VI which is in a 2D array to the nearest 5 decimal point. After rounding up, i want to compare the rounded up values against the phase column so that I can get the value which is equal to or nearest to the values in the phase column to get my grey level value and show the grey level in a 2d array (50x50).

 

How do I go about doing it?

 

 

Download All
0 Kudos
Message 1 of 19
(5,021 Views)

Hi LHX,

 

like that:

check.png

- Use FOR loops to find corresponding grey levels for each input value.

- Keep in mind: rounding will still be not accurate due to floating point precision!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 19
(5,016 Views)

Hi,

 

I'm not sure, but tried some code around your requirement, please find it in the attachment.

 

Code.png

 

Attached code is saved in version 2009.


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


0 Kudos
Message 3 of 19
(5,009 Views)

you can also round to a defined number of decimal digits like this:

 

roundto.png

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
Message 4 of 19
(4,999 Views)

Hi Nghtcrwlr,

 

what's the FOR loop good for? 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 19
(4,998 Views)

Smiley Winkoops... ... sorry.. was trying something else also...

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 6 of 19
(4,993 Views)

Hi Nightcrwlr,

 

i've seen a similar VI like yours in the community page before but i don't understand exactly how it works and what is the function connected to the indicator for?

Could you explain it to me in depth?

0 Kudos
Message 7 of 19
(4,989 Views)

Hi LHX,

 

the icon of that function clearly says "10^x" - you should search the Math palette for it...

 


function connected to the indicator for


That's a Divide function. Pretty basic...

 

Can't you open the snippets on your computer?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 19
(4,991 Views)

Nghtcrwlr's solution will give you your number decimals.

 

Run the output of that with your greyscale array into Threshold 1D array.vi in double for loops and then round to nearest and you should be home.



CLA
www.dvel.se
0 Kudos
Message 9 of 19
(4,965 Views)

Hi Peeker,

 

Thereshold1DArray will not work for unsorted arrays, that's why I suggested to search the minimum deviation...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 19
(4,968 Views)