[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating "sequential variable names"
From: |
AlbFrigerio |
Subject: |
Re: Creating "sequential variable names" |
Date: |
Tue, 19 Oct 2010 01:48:38 -0700 (PDT) |
Wow, I never thought about this fact ... thank you so much!!!
Just a little consideration : I believe the inversion you suggested is
necessary only at the first time I create my struct, because from that
moment it has the "right" dimensions, hence if I want to modify something
(e.g. AG(i).P.n=10) I can use both the "regular" and the inverse loop and I
won't have any time difference, isn't it?
Thanks again,
Alberto
John W. Eaton wrote:
>
> On 19-Oct-2010, AlbFrigerio wrote:
>
> | Thanks a lot jwe, it looks very simple, as all the right things should
> be. I
> | implemented it and everything works without using eval or something like
> | that.
> |
> | > I think it is even clearer if you write
> | >
> | > for i = 1:10
> | > AG(i).P.n = 1;
> | > AG(i).M.err = 0;
> | > endfor
> | >
> | > to create a struct array.
>
> I should also mention that if you have a large number of elements in
> your struct array, the above will be somewhat slow because AG will be
> resized each time through the loop. It will be faster to write
> something like
>
> for i = 10:-1:1
> ..
> end
>
> so that resizing happens only once.
>
> jwe
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
>
--
View this message in context:
http://octave.1599824.n4.nabble.com/Creating-sequential-variable-names-tp3000216p3001691.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Re: Creating "sequential variable names", (continued)
- 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
- Re: Creating "sequential variable names",
AlbFrigerio <=
- Re: Creating "sequential variable names", Jaroslav Hajek, 2010/10/19