From: Zemax Mat on
I have a variable which contains strings separated by comma :

H = 'Hello,we,are,united';

I want to extract each word which is comma separated in the above variable and store them in a separate variable e.g.

a1 = 'Hello';
a2 ='we';
..
..
a4 = 'united'

I have tried sscanf but without any success. Is there any simple way of extracting words from above variable?

Thanks.
From: Sean on
"Zemax Mat" <zemax2000(a)yahoo.com> wrote in message <hqn0ip$kbp$1(a)fred.mathworks.com>...
> I have a variable which contains strings separated by comma :
>
> H = 'Hello,we,are,united';
>
> I want to extract each word which is comma separated in the above variable and store them in a separate variable e.g.
>
> a1 = 'Hello';
> a2 ='we';
> .
> .
> a4 = 'united'
>
> I have tried sscanf but without any success. Is there any simple way of extracting words from above variable?
>
> Thanks.

a = regexp('hello,world,woohoo!',',','split');
From: Zemax Mat on
"Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <hqn21o$jdh$1(a)fred.mathworks.com>...
> "Zemax Mat" <zemax2000(a)yahoo.com> wrote in message <hqn0ip$kbp$1(a)fred.mathworks.com>...
> > I have a variable which contains strings separated by comma :
> >
> > H = 'Hello,we,are,united';
> >
> > I want to extract each word which is comma separated in the above variable and store them in a separate variable e.g.
> >
> > a1 = 'Hello';
> > a2 ='we';
> > .
> > .
> > a4 = 'united'
> >
> > I have tried sscanf but without any success. Is there any simple way of extracting words from above variable?
> >
> > Thanks.
>
> a = regexp('hello,world,woohoo!',',','split');

Thanks for your suggestion but problem is that I only know that the data is comma separated I dont know what words are stored in the string. Instead of 'hello' it could have 'Data'.
From: Zemax Mat on
"Zemax Mat" <zemax2000(a)yahoo.com> wrote in message <hqn3gg$haa$1(a)fred.mathworks.com>...
> "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <hqn21o$jdh$1(a)fred.mathworks.com>...
> > "Zemax Mat" <zemax2000(a)yahoo.com> wrote in message <hqn0ip$kbp$1(a)fred.mathworks.com>...
> > > I have a variable which contains strings separated by comma :
> > >
> > > H = 'Hello,we,are,united';
> > >
> > > I want to extract each word which is comma separated in the above variable and store them in a separate variable e.g.
> > >
> > > a1 = 'Hello';
> > > a2 ='we';
> > > .
> > > .
> > > a4 = 'united'
> > >
> > > I have tried sscanf but without any success. Is there any simple way of extracting words from above variable?
> > >
> > > Thanks.
> >
> > a = regexp('hello,world,woohoo!',',','split');
>
> Thanks for your suggestion but problem is that I only know that the data is comma separated I dont know what words are stored in the string. Instead of 'hello' it could have 'Data'.

Thanks Seans. I used the code that you suggested and it worked perfectly fine.