LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to parse my datas into decimals

Hi all, i've been trying to convert my data from exponential form into decimal how should i go about doing it?
 
eventually, i will want to average out the data points(current) i got into a single value. Is there a better way to do so instead changing them into decimal form and try to average them again? Perhaps just do some formulas and get the final average value?
 
I'm using LV 7.1. attached is the program i've done.
 
thanks in advance
 
Rgds,
Linda
0 Kudos
Message 1 of 9
(3,525 Views)
Hi lknn,

what's 'exponential' and 'decimal'? Do you think of numbers like '1.234E+56' and '1234'? In your example vi you just show the device communication... (Btw. use the error cluster to avoid communication problems and to remove unneeded sequence structures!)

To get numbers from strings you should use functions like 'Scan from String'. You should stick with floating point numbers  when useful/making sense. You can always format your data display to just show non-fractional numbers.
When you get your values in a loop use the auto-indexing feature to get an array of measurement values. Now you simply apply a function from the math palette (Mean)...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(3,509 Views)

It seems that waht you want to do is convert your strings into numerics. That can be done with the Scan From String Function or Fract/Exp String to Number.

Do you want a running average or do you just want the mean when the last while loop is done. If it's a running average, you could use a shift register in the loop to hold the array of values. If the loop doesn't run tooo long, you could use the build array function, Otherwise, use the Insert Into Array. If at the end, all you have to do is wire the numeric through the while loop, right click on the exit tunnel, and select Enable Indexing.

p.s. Eliminate that sequence structure and use the error in/error out connections of the VISA functions in order to enforce dataflow.

0 Kudos
Message 3 of 9
(3,508 Views)

Hi GerdW,

You are right what i meant was changing "1.23E-2" to "0.0123".

However, i was not able to scan as my data result is a string that looks like this '2.87471E-4,-1.41954E-4,5.02184E-4,-1.41954E-4,-1.41954E-4' is there anything that i left out?

please pardon me for i might be slow with this program as i am a student only and i am working on a program as an individual project for my internship.Smiley Indifferent

Regards,
Linda

0 Kudos
Message 4 of 9
(3,490 Views)

Hi Dennis,

yup. what i wanted was to convert my strings into numerics. sorry for the confusion made earlier. what i meant was converting the displayed scientific values into decimal values.

In any case, if i would like to do a running average, how should i go about doing it?

fyi, i get many sets of '1.18594E-1,1.27397E-1,1.27183E-1,1.22674E-1,1.20527E-1' such string  depending on my sampling points. how should i average them?

thanks

rgds,
Linda

0 Kudos
Message 5 of 9
(3,482 Views)
Hi Linda,

I attached an example of using 'Scan from String' to convert your string to an array of numbers...

To do the formatting of numbers you should use 'Format into string' or set the formatting properties of your numeric indicators accordingly!
(There's a huge page in the online-help on formatting codes 🙂
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(3,481 Views)

In case that you don't know the amount of numbers in the string, a simple for loop would work.

Make a subVI's with something like this in it:

 

Message Edited by Anthony de Vries on 04-11-2007 11:37 AM

Message 7 of 9
(3,477 Views)

thanks anthony!

that was what i wanted. Now i gotta crack my brain on how to do either a running average, or a mean for all the data points i got.Smiley Happy

rdgs,
Linda

0 Kudos
Message 8 of 9
(3,456 Views)

Hi GerdW,

thanks for you help! Although ity wasn't exactly what i had asked for, but i'm sure i had learnt the right way to connect a 'scan from string' function. Smiley Wink

rdgs,
Linda

0 Kudos
Message 9 of 9
(3,454 Views)