From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-18-2013 10:14 AM
Dear all,
I have one string that is read from Excel like this: "-90 db, 10 us, 100 Hz" that is used in some tests. I can't change this format.
The numbers can change and the code should be generic for any number.
For an expecific case I would like to replace the second number (duration in us) for a decimal that I will calculate.
This means that I only have to find the second "%d" (decimal number in the string) and replace for another number.
Is there any VI for that? I have been trying with some of them inside loops with no sucess... Please I would like some tips.
Thank you,
Thais Marques
04-18-2013 10:55 AM - edited 04-18-2013 10:55 AM
One of the many possible ways:
Hope this helps.
04-18-2013 11:40 AM
Hi Thais
You can do something like this
1) Split string up in 3 bits by using the ,
2) Pull out what is between the 0 spaces og the middle string
3) Change this to a floating points tring with X number of precision
4) Build the string back up.
I have also attached the example in LabVIEW 2012 format.
Best Regards
Anders Rohde
Applications Engineer
National Instruments Denmark
04-18-2013 11:53 AM
Ugh, a pet peeve of mine. You capitalize the "H" in "Hz" - why not the "B" in "dB?" After all, they both refer to proper names. 😉
04-18-2013 12:31 PM
@billko wrote:
Ugh, a pet peeve of mine. You capitalize the "H" in "Hz" - why not the "B" in "dB?" After all, they both refer to proper names. 😉
Unit capitalization is one of my peeves as well. There's nothing quite like reading a test procedure and it says "Pulse the input for 500MS". 500 Megaseconds!???? Oh, you mean 500 milliseconds. That's 500ms (or if you really want to capiltalize the seconds, 500mS).
04-18-2013 12:43 PM - edited 04-18-2013 12:45 PM
dear gosh people.
i just typed myself this. that is a simplification of my string (because the whole problem is much bigger!);
What is the problem of one letter not capitalized?!!!!!!!!!!!!!!!!!!!! that is not the point of my question.
that is not a document, is not a report............ just a post!!
anyway thanks for who helped me really 🙂
04-18-2013 03:32 PM - edited 04-18-2013 03:35 PM
Use the 'Spreadsheet String To Array' then 'Fract/Exp String To Number' to give you an array of floats from the Excel spread sheet.
You can then pick and choose which item you need or skip over or replace.
I used a float because db and hz could be given as floating point
04-18-2013 03:46 PM
04-18-2013 04:22 PM
is there a reason to use two functions when one will do the same?
No. I first though the OP needed to replace a string keeping the output a string, So I started down that path keeping eveything as strings.
Then noticed their use of ["%d" (decimal number in the string)] in their original post and at the last just added the extra convertions.
If all they wished to do is change the 10 us then the search and replace with regular expersion turned on will work.
04-19-2013 03:04 AM - edited 04-19-2013 03:06 AM
I just realized that is possible that not necessary the string that is been read will be given in "us" because allows that you type in "ms" also.
So here goes my not-so simple solution: (with B capitalized :P)