<div dir="ltr">I'm confused as to what you are trying to do.<div><br></div><div>Meshgrid is used to create a regular grid when you have a vectors of the axes.<br><div class="gmail_extra"><br></div><div class="gmail_extra">It support 2 or more dimensions.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have two arrays of size N (let's say 2 arrays of length 4) that I combine using np.meshgrid<br>
<br>
xxA, yyA = np.meshgrid(xA, yA)<br>
xxB, yyB = np.meshgrid(xB, yB)<br>
<br>
which gives me two meshes<br>
<br>
xx.shape = yy.shape = (4,4)<br>
which represent a N-dimensional mesh with 16 elements.<br></blockquote><div><br></div><div>no -- it represents a 2-dimensional mesh with four nodes in each direction.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Now I want to evaluate a function f on every possible pair of N-dimensional points in the grid, resulting in a 16 x 16<br>
matrix:<br></blockquote><div><br></div><div>I think you are looking for a different function than meshgrid.</div><div><br></div><div>But if you want to evaluate a function on a four dimensional space, you can use meshgrid with four dimensions:</div><div><br></div><div><font face="monospace, monospace">xx, yy, zz, tt = meshgrid(x, y, z, t)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">results = func(xx,yy,zz,tt)</font></div><div><br></div><div>note that with numpy's broadcasting, you may not need to use meshgrid at all.</div><div><br></div><div>Is that what you are looking for?</div><div><br></div><div>-CHB</div><div><br></div></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R (206) 526-6959 voice<br>7600 Sand Point Way NE (206) 526-6329 fax<br>Seattle, WA 98115 (206) 526-6317 main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div></div>