[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Empty matrix question
From: |
Wonkoo Kim |
Subject: |
Re: Empty matrix question |
Date: |
Tue, 10 Feb 98 16:20:25 -0500 |
> Date: Tue, 10 Feb 98 12:00:15 -0700
> From: "Andy Adler" <address@hidden>
> Subject: Empty matrix question
>
> I'm having a problem with empty matrices.
>
> There's probably an octave preference variable to do this
> but I couldn't find it. (So far 90% of my questions to
> help-octave have been answered by a preference variable)
>
> Anyway, here's the sample code
>
> octave:54> vector=ones(1,5);
> octave:55> numfix=0;
> octave:56> vector(1:numfix)=zeros(numfix,1);
> error: A([]) = X: X must also be an empty matrix
> error: evaluating assignment expression near line 56, column 17
>
> "numfix" is not necessarily zero in the "real" code, but can
> be zero if there are no elements to "fix"
I don't see a statement in a octave's doc, but I would recommend you
to allocate memory (i.e. assign) without indexing. So the above can
be done as
octave:1>numfix = 5
numfix = 5
octave:2>vector = zeros (numfix, 1)
vector =
0
0
0
0
0
octave:3>
> I realize that I could fix this code using something like
>
> octave:56> vector(1:numfix)=zeros(numfix, (numfix>=1) );
This does not solve.
//--------------------------------------------------------------------
// Wonkoo Kim (address@hidden)