> Dear All,
>
> I wish to write
>
> Cat1 = 4
> Cat2 = 5
> Cat3 = 6
>
> (p/s: there are no space between 'cat' and numbers)
>
> However I want to do it with "for" command.
>
> For example;
> for i=1:3
> Cati=i+3;
> end
>
> And the answer will be
>
> Cat1 = 4
>
> Is there any way do it?
>
> Really appreciate your helps. Thank you.
>
> -suli-
>
>
>
--
Baran USLU, M.Sc.
Ogr.Gor.
Baskent Universitesi
Elektrik-Elektronik Muhendisligi Bolumu
You can do this
for i=1:3
eval(['cat',num2str(i),'=i+3;']);
end
But, this will drastically slow down your execution time and makes code
readability more harder. I strongly discourage such coding style.
Cheers,
Tilak
On Thu, Dec 24, 2009 at 8:22 AM, Tengku J wrote:
> Dear All,
>
> I wish to write
>
> Cat1 = 4
> Cat2 = 5
> Cat3 = 6
>
> (p/s: there are no space between 'cat' and numbers)
>
> However I want to do it with "for" command.
>
> For example;
> for i=1:3
> Cati=i+3;
> end
>
> And the answer will be
>
> Cat1 = 4
>
> Is there any way do it?
>
> Really appreciate your helps. Thank you.
>
> -suli-
>
>
>
Reply by Tengku J●December 24, 20092009-12-24
Dear All,
I wish to write
Cat1 = 4
Cat2 = 5
Cat3 = 6
(p/s: there are no space between 'cat' and numbers)