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

Re: Array To Veriable

$
0
0
On 12/4/2012 5:38 PM, Tony wrote:
> dpb <none@non.net> wrote in message <k9lve9$60g$1@speranza.aioe.org>...
...

>> Well, I'm not sure if this is what you mean by 'SOS' output or not,
>> but just in case...
>>
>> > x=[0 0 1 3 1 3 1 4 2 3 2 3 2 4 1 3 1 3 1 0 1 3 1 3 1 3 3 4 1 3 1 3 1
>> 0 1 3 1 3 1 4 4 3];
>> >> xc=sprintf('%d',x);
>> >> s=sprintf('%d',[1 3 1 3 1]);
>> >> o=sprintf('%d',[2 3 2 3 2]);
>> >> b='4';
>> >> z=strrep(xc,s,'S');
>> >> z=strrep(z,o,'O');
>> >> z=strrep(z,b,' ')
>> z =
>> 00S O S0S33 S0S 3
>> >>
>>
>> The above can be generalized, of course, and you'll have to decide how
>> to deal w/ the '0' and the digit sequences that don't fit any defined
>> pattern...
>>
>> --
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Hi, thanks. But what i want is only characters and space. And how to
> make output looks like:
> ~~~~~~~~~~~~~~~~~
> S
> O
> S
>
> S
> O
> S
> ~~~~~~~~~~~~~~~~~

Then you'll have to make the input match the conversion rules...as I
said, you've got some data that doesn't fit the rules you described.
Only you can decide what to do to augment those rules...simplest would
be to simply take everything that isn't ismember('SO ') and remove it in
the final result but whether that meets your need or not only you can
tell...

--

Viewing all articles
Browse latest Browse all 19628

Trending Articles