dpb
Posts:
6,692
Registered:
6/7/07
|
|
Re: Help using textscan or sscanf
Posted:
Jan 17, 2013 10:18 AM
|
|
On 1/16/2013 4:33 PM, dpb wrote: ....
> The solution I gave reproduced your values for your sample set...
OBTW, NB "the trick" in the above solution--horzcat() or shorthand of [s1 s2] where s1,s2 are character arrays will transparently "eat" intervening blanks to create the shorter lengths automagically you're working so hard to create..."use the (hidden) force, Luke..." :)
That's what eliminates the need for all the string parsing and just lets it pick the last N desired characters--when were blank-filled and right-adjusted in strvcat(), then when the concatenation of the prepended string occurs, the spurious blanks go away on their own w/ no additional effort.
I was simply noting elsewhere it _might_ be convenient to have a fixed length for reporting purposes or for sorting by prepending the zeros in place of blanks so the numeric order would be preserved and columns would be same width, etc., etc., etc., ... Again, that would be purely application-specific as to what is actually being done w/ them.
HTH...
--
|
|