using default for unitialized variable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

using default for unitialized variable

Daniel Heiserer
Hi,
I have to do a loop in which I have to continously
add a row:

IN=zeros(0,30);
for jj=1:10000
IN=[IN;R']
end

Unfortunately I have to initialize
an emtpy array (see above) otherwise
octave does not allow to use
the IN on the right side.

Is this a bug or a feature?

Thanks daniel



-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: using default for unitialized variable

Etienne Grossmann-4
  Hello,

  what about :

L=10000;
IN=zeros (L,30);
for i=1:L, IN(i,:)=R'; end

  ?

  Etienne



-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

Re: using default for unitialized variable

Joao Cardoso-3
In reply to this post by Daniel Heiserer
Daniel Heiserer wrote:

>
> Hi,
> I have to do a loop in which I have to continously
> add a row:
>
> IN=zeros(0,30);
> for jj=1:10000
> IN=[IN;R']
> end
>

I'm not shure of what you want, but will not

R=1:5
a=ones(10,1)*R

Or even a=R(ones(10,1),:)

solve the problem?

Joao

> Unfortunately I have to initialize
> an emtpy array (see above) otherwise
> octave does not allow to use
> the IN on the right side.
>
> Is this a bug or a feature?
>
> Thanks daniel
>
> -----------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
> How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
> Subscription information:  http://www.che.wisc.edu/octave/archive.html
> -----------------------------------------------------------------------



-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------