Steve on Image Processing

Concepts, algorithms & MATLAB

More about meshgrid 3

Posted by Steve Eddins,

Reader Philip Batchelor thought I could do better in describing meshgrid. I had commented that "meshgrid is kind of hard to describe in words."

Well, maybe I was being a bit lazy there, as well as unfair to our writers! Here's what the meshgrid documentation says:

[X,Y] = meshgrid(x,y) transforms the domain specified by vectors x and y into arrays X and Y, which can be used to evaluate functions of two variables and three-dimensional mesh/surface plots. The rows of the output array X are copies of the vector x; columns of the output array Y are copies of the vector y.

That works!

Thanks, Philip. Keep those comments coming, everyone.

Note

Comments are closed.

3 CommentsOldest to Newest

Vijay replied on : 1 of 3

Hi Steve,
How can I suppress plotting in windows version of Matlab? For instance, assume I have the following code segments:
h1 = surf(linspace(1,100),linspace(1,100),ones(100)*10);
rotate(h1,[0 0 1],30,[50 50 10])
x = get(h1,’XData); y = get(h1,’YData);
z = get(h1,’ZData);
Now, this will display the plots and only then will it get me the data that I want: x,y,z. However, when I am cranking through a long computation, I want to disable the plotting although I issue the commands for the sake of the data. Under unix, I can do something like
-nodisplay which will take care of this. Is there a similar command/option under windows xp?
Alternately, is there a more efficient way of doing this: rotating a surface and getting the data.

Thanks,
Vijay

Steve replied on : 2 of 3

Vijay – Your question is a bit off topic for an image processing blog, but I’ll give it a shot anyway. Try plotting into an invisible figure:

>> fig = figure('Visible', 'off');
Manikandan Raj replied on : 3 of 3

Hi Steve,
I started reading your blog just today and I understood this topic clearly.
I think the following description will be much useful for starters like me.

here we go….

meshgrid(a)
it gives output ‘a’

meshgrid(a:b)
for example:
meshgrid(1:5)

it gives all the values between 1 & 5 including 1 & 5 represented as a matrix below, with number of rows equal to no of values between 1 & 5.

1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

meshgrid(1:5,x)
it gives all the values between 1 & 5 including 1 & 5 represented as a matrix with 1 row. where x can be any number.

for example:
meshgrid(1:5,1)

1 2 3 4 5

meshgrid(1:5,79)

1 2 3 4 5

meshgrid(1:5,x:y)
it gives all the values between 1 & 5 including 1 & 5 represented as a matrix with with number of rows equal to no of values between ‘x’ & ‘y’. where x,y can be any number and it should obey the condition (x<y).

for example:
meshgrid(1:5,1:3)

1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

meshgrid(1:5,1:5)
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5