|
"omegayen " <omegayen@ameritech.net> wrote in message <k54r74$6i9$1@newscl01ah.mathworks.com>...
> Hi,
>
> So I have a cell array of a cell array of strings that I am working with.
>
> As an example consider the following:
>
> test=cell(5,1);
> test{1,1}{1}=num2str(1);
> test{1,1}{2}=num2str(0);
> test{2,1}{1}=num2str(0);
> test{2,1}{2}=num2str(0);
> test{3,1}{1}=num2str(1);
> test{3,1}{2}=num2str(1);
> test{4,1}{1}=num2str(0);
> test{4,1}{2}=num2str(0);
> test{4,1}{3}=num2str(0);
> test{5,1}{1}=num2str(0);
> test{5,1}{2}=num2str(1);
> test{5,1}{3}=num2str(0);
>
> I want to process this cell array of cell array of strings so that the inside cell array is removed to make it easier to analyze and look at the results.
>
> Hence I can use the following code to do this and separate the strings in each row of the outer cell array with commas
>
> test2=cellfun(@(x){strcat(x,',')},test)
> test2=cellfun(@(x) {deblank([x{:}])},test2);
>
> However, when I do this I get an extra comma (,) at the end. Does anyone know how I can do something similar but not have this extra comma (,) at the end of each row of test2 in this case?
>
> Note: disregard that the strings are 1's and 0's in the sample as they can also be actual alphabet characters
example:
"cellstr" is a cell array of cell array of strings
cellstr = { {'why hello there'}; {'matlab is fun}; {'12345abc'}};
newcellstr = [cellstr{:}];
Then newcellstr is a cell array of strings, like:
newcellstr = {'why hello there'; 'matlab is fun; '12345abc'};
The key is in this bracket notation.
If you just type cellstr{:} into the command prompt, you will see the contents of the cells, but as three different outputs... Putting the square brackets around this remedies the situation. Hope this helps!
|