[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating "sequential variable names"
From: |
Andy Buckle |
Subject: |
Re: Creating "sequential variable names" |
Date: |
Mon, 18 Oct 2010 14:29:49 +0100 |
On Mon, Oct 18, 2010 at 2:21 PM, AlbFrigerio
<address@hidden> wrote:
>
> Hello world, I've got a problem in defyining "sequential name variable" . I
> would like to create name variables such as b1, b2, b100 and to assign them
> values, e.g. b1=1, b2=2, ... , b100 = 100. I would obviously not to assign
> every variable at once, I'd like to use a for loop similar to
>
> for i = 1:100
> bi=i;
> endfor
>
> This is not the right answer, but I don't know how to create sequentially
> name variables like b1, b2, etc. I could create a string name
> strcat("b",nu2str(i)) , but I don't solve my problem. I got the same problem
> using b_i = i, does anyone have an idea?
>
> Thanks everybody, have a nice day,
> Alberto
(I am wondering why you don't use an array.)
for i = 1:10
evalstr=sprintf("b%i=%i;",i,i);
printf("%s\n",evalstr);
eval(evalstr);
endfor
--
/* andy buckle */
- Creating "sequential variable names", AlbFrigerio, 2010/10/18
- Re: Creating "sequential variable names",
Andy Buckle <=
- Re: Creating "sequential variable names", Søren Hauberg, 2010/10/18
- Re: Creating "sequential variable names", AlbFrigerio, 2010/10/18
- Re: Creating "sequential variable names", Ben Abbott, 2010/10/18
- Re: Creating "sequential variable names", Søren Hauberg, 2010/10/18
- Re: Creating "sequential variable names", AlbFrigerio, 2010/10/18
- Re: Creating "sequential variable names", John W. Eaton, 2010/10/18
- Re: Creating "sequential variable names", Sergei Steshenko, 2010/10/18
- Re: Creating "sequential variable names", John W. Eaton, 2010/10/18
- Re: Creating "sequential variable names", AlbFrigerio, 2010/10/19
- Re: Creating "sequential variable names", John W. Eaton, 2010/10/19