help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vector assignment problems


From: Jaroslav Hajek
Subject: Re: Vector assignment problems
Date: Mon, 16 Aug 2010 10:40:15 +0200

On Sun, Aug 15, 2010 at 11:08 PM, Ben Price <address@hidden> wrote:
> Hi,
>
> I see that
>> [a,b] = size([1,2])
> works, but
>> [a,b] = [1,2]
> gives ``error: invalid number of output arguments for constant expression''
>
> What am I missing?
>
> TIA,
> Ben
>

When multiple targets are given on the lhs, the rhs needs to produce
at least as many values. [1,2] does, however, produce a single vector
value. You can either do:

[a, b] = deal (1, 2);

or

[a, b] = {1, 2}{:};

hth

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]