Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: Extract values from a string

$
0
0
On 12/15/2012 2:29 PM, Khaled Hamed wrote:

...[top posting repaired--please don't do that; hard conversation follow
makes]...

> dpb <none@non.net> wrote in message <kaihsc$t56$1@speranza.aioe.org>...
...

>> >> a = '1.4.6.5.11';
>> >> sscanf(a,'%d.')
...

>>
>> BTW, the much ballyhoo'ed textscan() barfs on this one...
>>
>> >> textscan(a,'%d.')
>> ans =
>> [3x1 int32]
>> >> ans{:}
>> ans =
>> 1
>> 7
>> 11
>> >> >> textscan(a,'%d','delimiter','.')
>> ans =
>> [3x1 int32]
>> >> ans{:}
>> ans =
>> 1
>> 7
>> 11
>> >>


 > textscan(a,'%2d') %works fine
 >
 > ans =
 > [5x1 int32]
 >
 >>> ans{:}
 >
 > ans =
 >
 > 1
 > 4
 > 6
 > 5
 > 11

Well, why does it need the '2' in the '2d' and what if the string is
only slightly different???

 >> a = '1.14.6.5.11';
 >> textscan(a,'%2d')
ans =
     [6x1 int32]
 >> ans{:}
ans =
            1
           14
            1
            1
            0
            1
 >>

It's broke...

--

Viewing all articles
Browse latest Browse all 19628

Trending Articles