09-10-2010 12:29 PM
Hello,
I'm reading DBL sample rate values from different RF bands and using the value to create a file header in order to store complex 32IQ binary data to file. I'm using the format into string function to do this but I always want the sample rate to be represented in kHz and I haven't thought of a way to force this to always be the case. I'm using a format string of %.3p which for sample rates such as 13125 and 400000 it returns 13.125k and 400.000k respectively and that is what I want. However, one of my bands is 3750000 Hz and the format into string returns 3.750M. I would like it to return 3750.000k instead. Anyone have any ideas on how I could accomplish this?
Thank you,
Tim
Solved! Go to Solution.
09-10-2010 01:11 PM
Tim,
Since the 3.750M is the correct format for the value and what you want is valid but not standard, you will need to do your own formatting.
You need to test the string coming from the format function. If it contains "M" then multiply by 1000 and append "k".
Lynn
09-10-2010 01:11 PM
09-10-2010 01:30 PM
I would guss that the internal code that shows the SI units is using the 'multiples of three' flag to determine the magnitude. If you use the advanced properties to select between engineering and SI units, the 'multiples of three' box is disabled when you select SI.
I experimented with various display formats, but could not get the combination you indicated.
I believe the SI standard reccommends that prefixes for which the exponent is divisible by three are used.( http://en.wikipedia.org/wiki/SI_prefix#List_of_SI_prefixes )
LabVIEW is displaying the number to the SI standard. Your desired display type is not standard SI units (although it may be common and practical in your environment/industry).
09-13-2010 09:42 AM - edited 09-13-2010 09:44 AM
Just as Ben said was the way I decided to implement it.
My numeric data inputs are always in Hz. So, I just always divide the DBL values by 1000 before inputting them into the "format into string" function and changed the format string to output %.3f. This way, the output was in kHz just without the letter suffix. I just append "k" myself afterwards. Thanks Ben.
I was trying to condense the multiple steps all into the "format into string" function but it wouldn't work for all my sample rate values.
-Tim
09-13-2010 11:12 AM
There's no need to 'add the "k" afterwards' if you use "%.3fk" as the format specifier in your format to string.
Rod.
09-13-2010 11:19 AM
Good point. I forgot that I could add non-conversion related text into the format string. Helps clean up the diagram a little bit too.
Thanks,
Tim