Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Handling arrays
Date: Thu, 17 Nov 2011 03:40:28 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 20
Message-ID: <ja1vnc$qlk$1@newscl01ah.mathworks.com>
References: <ja1ncm$35b$1@newscl01ah.mathworks.com> <ja1tlp$krq$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1321501228 27316 172.30.248.46 (17 Nov 2011 03:40:28 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 17 Nov 2011 03:40:28 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3185020
Xref: news.mathworks.com comp.soft-sys.matlab:749626

"Roger Stafford" wrote in message <ja1tlp$krq$1@newscl01ah.mathworks.com>...
> "William" wrote in message <ja1ncm$35b$1@newscl01ah.mathworks.com>...
> > nx=[nx_min:1:nx_max];
> > ny=[ny_min:1:ny_max];
> > nz=[nz_min:1:nz_max];
> > 
> > Basically what I want 'E' to be is the sum of all the possible combinations of nx, ny, and nz.
> - - - - - - - - - -
>   Matlab already has a routine that accomplishes this.  It is called 'ndgrid'.  No need for 'for loops' here.
> 
>   [Nz,Ny,Ny] = ndgrid(nz_min:nz_max,ny_min:ny_max,nx_min:nx_max);
>   E = Nz(:) + Ny(:) + Nx(:);
> 
> Roger Stafford

Thanks Roger, before you replied I figured out how to do it with loops! But thanks for the help and good to know for future reference.

I'm having one other array issue though.

I'm trying to pass an array of varying size to another array. Something simple like x = y; where y is an array of [1:x] dimensions. When I do this and look at y, is has the proper size [1:x] but only the first cell copies. Any suggestions?