From: aashay vanarase on
i'm trying to add string objects to a array inside a loop,
the problem i am encountering is that by using the...
a=[a, b]
command, instead of conc the array and adding new string, it is conc all the strings..

any solutions...
i know it is something silly... i just cant get it...

thx
From: aashay vanarase on
or else.. how can i create a empty string array...
ie how do i say it is string array
From: Oleg Komarov on
"aashay vanarase" <aashayv(a)gmail.com> wrote in message <hntggp$e3o$1(a)fred.mathworks.com>...
> i'm trying to add string objects to a array inside a loop,
> the problem i am encountering is that by using the...
> a=[a, b]
> command, instead of conc the array and adding new string, it is conc all the strings..
>
> any solutions...
> i know it is something silly... i just cant get it...
>
> thx

Use cell arrays of strings:
a = {'Hello'};
b = {'Hi'};
a = [a,b];

Oleg
From: Matt J on
"aashay vanarase" <aashayv(a)gmail.com> wrote in message <hntggp$e3o$1(a)fred.mathworks.com>...
> i'm trying to add string objects to a array inside a loop,
> the problem i am encountering is that by using the...
> a=[a, b]
> command, instead of conc the array and adding new string, it is conc all the strings..
>
> any solutions...


c=cell(1,N);

for i=1:N
c{i}=newstring;
end

finalstring=[c{:}]; % Better than growing string inside loop!!!!