[scilab-Users] Keeping track of for loops
Matthew Albrecht
mattyalbrecht at gmail.com
Sat Mar 1 10:35:26 CET 2008
I'm now having problems getting this to work with a matrix. The string
function only outputs the sum from the last item in the matrix.
e.g.
for i=1:5
x=[1:5;6:10];
execstr('x'+string(i)+'='+string(i*x))
end
x3=
30
but I need the full matrix outputted i.e.
x3=
3. 6. 9. 12. 15.
18. 21. 24. 27. 30.
Matt
On 01/03/2008, Matthew Albrecht <mattyalbrecht at gmail.com> wrote:
>
> Thanks, works well.
>
> On 29/02/2008, Eric Dubois <grocer.toolbox at gmail.com> wrote:
> >
> > Do :
> >
> > for i=1:n
> > execstr('x'+string(i)+'='+string(i))
> > end
> >
> > Or more efficiently (but less general) :
> >
> > execstr('x'+string([1:n])+'='+string([1:n])
> >
> > Eric.
> >
> >
> > 2008/2/29, Matthew Albrecht <mattyalbrecht at gmail.com>:
> > >
> > > I would like to keep track of the output of a for loop, so that each
> > > output is assigned sequentially to a new variable from 'x1' to 'xn'.
> > > In its most simplest form, I would like to be able to do this:
> > >
> > > for i=1:n
> > > x=i
> > > end
> > > x1=1
> > >
> > > x2=2
> > >
> > > ....
> > >
> > > xn=n
> > >
> > >
> > > Where currently it outputs
> > > x=1
> > >
> > > x=2
> > >
> > > ...
> > >
> > > x=n
> > >
> > >
> > > Thanks
> > > Matt
> > >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20080301/62f3187d/attachment.htm>
More information about the users
mailing list