On Friday, February 27, 2015 at 9:11:10 AM UTC-5, antony schutz wrote:
>
> I have a question about the best way to implement a grid similar to a mesh 
> grid: 
>

 Note that you normally don't need mesh-grid like things, because you can 
use broadcasting operations instead.  e.g. in order to compute z = sin(x) * 
cos(y) on a 2d grid, you can use 1d x and y arrays:

x = linspace(0, 10, 100)
y = linspace(-2, 3, 50)'
z = sin(x) .* cos(y)

The .* operation is broadcasting: if you give it a row and column vector as 
arguments, the output is a matrix.

You can also implement repmat the same way, if needed:

X = x .* ones(1,50)

will make a 100x50 matrix whose columns are x, repeated 50 times.

Reply via email to