Plotting z values associated with xy coordinate for 3d plot

I am trying to plot a 3d plot for a magnetic data set. Each z value is associated with an x,y coordinate.
For example there may be some point 1,2 with a value of 67. This in turn would plot on the xy plane at 1,2, but would have point at 67.
I want to do this for a major data set with lots of points so I cannot post my code.
Here is what I did:
I imported the data from an excel spread sheet. I set the x coordinates as x = [...], y = [...], and z = [...]. Each vector is the same dimension.
Then i did:
figure;
axis([xmin xmax ymin ymax zmin zmax]);
meshc(X,Y,Z);

5 件のコメント

Walter Roberson
Walter Roberson 2013 年 2 月 21 日
How does the result you get differ from the result you want?
Colton
Colton 2013 年 2 月 21 日
編集済み: Walter Roberson 2013 年 3 月 17 日
Here is my code, but I did not include the data for x,y,z. x,y, and z are both 1371x1 matrices. This code did nothing but produce a cube with the dimensions desired:
x = [...];
y = [...];
z = [...];
figure;
axis([288000 290000 4435000 4438000 50100 53100]);
mesh(x,y,z);
I also tried this code, but it produced only a plane across the cubed grid:
x = [...];
y = [...];
z = [...];
figure;
[X,Y] = meshgrid(x,y);
Z = peaks(X,Y);
meshc(Z);
Colton
Colton 2013 年 2 月 21 日
The code is indented with every colon, like a typical code.
Colton
Colton 2013 年 2 月 21 日
Additionally, my x,y,z values look something like:
x = [ 22.343;55.66;89.3432;...]
and all are 1371x1
Wouter
Wouter 2013 年 3 月 17 日
Hi Colton,
A simple solution might be using the plot3 function. You can use griddata to create a surface through your data points. See the help file for griddata.

サインインしてコメントする。

回答 (1 件)

Omid Adljuy
Omid Adljuy 2013 年 4 月 5 日

0 投票

If you want to plot a 3D surface using your dataset, then the patch command shall help you. However, the patch command requires an additional Faces matrix. Faces matrix defines the points that must be connected to each other to form the triangles of the mesh of the 3D structure.
Besides the patch command, this tutorial video might be of use as well.

カテゴリ

質問済み:

2013 年 2 月 21 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by