help-octave
[Top][All Lists]
Advanced

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

Re: name variable


From: bpabbott
Subject: Re: name variable
Date: Fri, 16 Jul 2010 12:39:12 -0700 (PDT)

On 16 Jul, 2010,at 02:55 PM, insipido <address@hidden> wrote:

I am trying to understand someone else's .m function and I run into an
argument declared this way:
n = 2;
x = [ 1 2 3 4];
[y{n:-1:1}] = ndgrid (x) = ndgrid (x)
I can see that ndgrid (x) = [ 1 2 4 ; 1 2 3 4 ; 1 2 3 4 ; 1 2 3 4 ]
but I don't understand the [y{n:-1:1}]...

can someone help me understand this.

thanks

/ vic /
 
Try the following ...

x = 1:4;
[a] = ndgrid (x)
[a, b] = ndgrid (x)
[a, b, c] = ndgrid (x)

The behavior of ndgrid depends upon the number of outputs. Thus ...
 
The "[y{n:-1:1}] = ndgrid (x)" effectively expands out to ...

[y{2}, y{1}] = ndgrid (x);

Ben

reply via email to

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