Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng 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
Joined
Apr 18, 2006
Messages
3
Location
GB
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
 
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

Back
Top