MATLAB: Converting tabulated data to 3D plot

surface 3d plot by tabulated data

Hi,
I have the attached table. I would be grateful if you can tell me how to show it in 3D ( Red–> x ; Green–> Y & White cells–>Z)
Thanks, Ehsan

Best Answer

Hi,
define a vector x
x = [0 10 30 60 120 -10];
define a vector y
y = 1000:1000:7000;
and calculate/write your z values in a matrix z = [size(y), size(x)].
In this example i use random integers:
z = randi(100,length(y),length(x));
Then use the surf function:
surf(x,y,z)
to get a 3D surface plot from your data.
Note that this procedure sorts your vector x in ascending order. if you want to avoid this, use:
surf(z)
and change the values that are used for the labeling of the axes by using your values from x and y.
Best regards
Stephan
Related Question