05-25-2017 03:37 PM
In MatLab 2014a I can make the following:
mycell = strcat(num2str([1,2,3,7,8,9],'%02d'));
it gives:
mycell =
010203070809
You can notice how it pre-pended zeros in the text.
How do I get that in MathScript, or LabVIEW?
Note, I would have asked in the MathScript forum, but that forum is dead. My previous post there is the 4th most recent, and it is from February. The newest post there is 3 days old and doesn't have a single view or reply.
Solved! Go to Solution.
05-25-2017 04:00 PM
05-25-2017 04:01 PM
The easiest way to do this is to use precisely the same format (%02d) by passing your numbers into a "format into string" node.
Unfortunately these nodes don't handle arrays so you will have to run through a for loop if you want to iterate through the array.
Other options include the "number to decimal string" but that won't automatically prepend the zeros, the "number to hexadecimal string" will prepend zeros if you set the minimum width but unfortunately is in hex.
05-25-2017 04:10 PM - edited 05-25-2017 04:13 PM
Right, that's a good point. My solution will prepend ANY integer with a 0, %02d will only prepend 0-9 with a 0.