Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mesh Plots using 3 Vectors

Status
Not open for further replies.

tommyears

Industrial
Apr 18, 2006
3
Hi All,

I would like to create a square array i.e 4x4 and then plot a vector of data (16 elements) over this 4x4 array.

I have created the following code, it doesnt work but thats what I am ideally aiming after:

[X,Y] = meshgrid([1:1:4]);

z = [30 20 20 30 20 10 10 20 20 10 10 20 30 20 20 30];

mesh(X,Y,z)

The reason that I believe that it doesnt work is that my z variable is not a funtion of X or Y. But it isn't in real life so how do I get around this?

Regards

Tom
 
Replies continue below

Recommended for you

Hi,
I thing, everything goes well as you suggested...
X=[1:1:4];
Y=X;
Z=[30 20 20 30; 20 10 10 20; 20 10 10 20; 30 20 20 30];
[X1,Y1]=meshgrid(X,Y);
mesh(X1,Y1,Z);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor