[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: append numbers to variable
From: |
Gerald Ebberink |
Subject: |
Re: append numbers to variable |
Date: |
Thu, 07 Sep 2006 08:03:59 +0200 |
something like this:
x=0;
for i=1:5
command=sprintf("x%d=%d",i,i);
eval(command);
endfor
On Wed, 2006-09-06 at 17:25 -0700, the_verge wrote:
> I have a question related to my last one, but it's slightly different:
>
> What I would like to do is, in a for loop, create a new variable with the
> current index of the loop appended. For example:
>
> x=0;
> for i=1:5
> x[append number i] = x+i;
> endfor
>
> It should output the following:
> x1 = 1
> x2 = 2
> x3 = 3
> x4 = 4
> x5 = 5
>
> So the for loop should have created 5 new variables and assigned them
> values.
>
> Any ideas?
>
--
NCLR B.V.
Visiting address Postal address
Drienerlolaan 5 PO box 2662
7522 NB Enschede 7500 CR Enschede
Netherlands Netherlands
Phone : (+31) (0)53-489 11 10 - Fax : (+31) (0)53-489 11 02
Direct line (+31) (0)53-489 39 61