Matlab: Append unique strings into one cell with comma seperation -


my input n unique strings of different length stored in structure such as

a.data{1} = {'the cat has'} a.data{2} = {'green eyes'} 

such a.data nx1.

the desired output 1,1 cell unique strings following each other , separated commas.

output = ['the cat has' ', ' 'green eyes'] 

which produces the cat has, green eyes want n strings.

any ideas?

thanks!

use strjoin:

a.data{1} = 'the cat has'; a.data{2} = 'green eyes'; result = strjoin(a.data, ', '); 

gives

result = cat has, green eyes 

if data has nesting level:

a.data{1} = {'the cat has'} a.data{2} = {'green eyes'}; 

you need rid of with

b = cellfun(@(x) x, a.data); 

before calling strjoin:

result = strjoin(b, ', '); 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -