How to create a 3D surface, then plot peaks at specific points on the 3D surface?
Show older comments
I want to plot a 3D surface that is 0 to 4 on the x-axis, 0 to 1 on y-axis and 0 on the z-axis (or some z if necessary like 0 to 1). Then I want to plot peaks on that surface, given the x, y, and z coordinates of the peak on the surface.
The data looks similar to:
if true
% Data (not code)
x y z
0.75 0.23 -2.86
0.75 0.47 3.87
0.75 0.64 2.78
2.45 0.23 4.56
2.45 0.47 0.89
2.45 0.64 2.74
3.23 0.23 2.10
3.23 0.47 -3.65
3.23 0.64 -5.89
Each row of the data is the x, y, and z coordinate of a specific peak on the 4 by 1 (0 to 4 on the x-axis, 0 to 1 on y-axis and 0 on the z-axis) surface.
The code that I am using now (written by Stephen Cobeldick ):
if true
close all
a=[0.75 0.23 -2.86
0.75 0.47 3.87
0.75 0.64 2.78
2.45 0.23 4.56
2.45 0.47 0.89
2.45 0.64 2.74
3.23 0.23 2.10
3.23 0.47 -3.65
3.23 0.64 -5.89]
x = reshape(a(:,1),3,3);
y = reshape(a(:,2),3,3);
z = reshape(a(:,3),3,3);
surf(x,y,z, 'FaceColor','interp')
end
This results in this:

This code sort of works in the sense that it shows the distortion of the data a crossed a surface, but it would be ideal to create a 4 by 1 (0 to 4 on the x-axis, 0 to 1 on y-axis and 0 on the z-axis) surface and then create specific peaks on that surface.
The end result that I am looking for is something that resembles this:

I would really appreciate any code that would help me to accomplish this goal.
Thank you
3 Comments
Ethan Gros
on 8 Jun 2015
Edited: Ethan Gros
on 8 Jun 2015
Walter Roberson
on 8 Jun 2015
So what do we do with the other post? Are you planning to mark the existing response there as Accepted?
Accepted Answer
More Answers (0)
Categories
Find more on Geographic Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!