Convert comma separated string to cellarray

  • Follow


Hi Matlab users 

I have a string like:

string=['test1', 'test2','test3']

I want to convert the string to a cellarray:

cellarray={'test1', 'test2','test3'}

Best Regards

Jens
0
Reply jens 5/21/2010 9:31:06 AM

you are using here the concatenation syntax (see strcat in the help) 
Therefore, string is equal to 'test1test2test3'
Use a string matrix ['test1'; 'test2';'test3'] and then cellstr to create a cell array. 

H. 
0
Reply Herve 5/21/2010 10:58:04 AM


"Herve " <michaud_rene@yahoo.fr> wrote in message <ht5ovs$q8l$1@fred.mathworks.com>...
> 
> you are using here the concatenation syntax (see strcat in the help) 
> Therefore, string is equal to 'test1test2test3'
> Use a string matrix ['test1'; 'test2';'test3'] and then cellstr to create a cell array. 
> 
> H. 

Thanks Herve

It works perfect

Best Regards

Jens
0
Reply jens 5/21/2010 12:50:20 PM

2 Replies
615 Views

(page loaded in 0.934 seconds)

Similiar Articles:













7/24/2012 1:06:48 AM


Reply: