how to use mesh to plot 3D image

1 Ansicht (letzte 30 Tage)
Clark
Clark am 22 Mär. 2013
i want to plot a figure like the attached addressURL. but i cant really know how to use the "mesh". please help me and correct the code. thanks you a lot!
https://www.dropbox.com/s/bxmrdjxazc4b84k/243950433810.jpg
clc; clear; close all figure; [X,T] = meshgrid(-2:.1:2 , 2:-.1 :0); Z = (X.^2)./T;
%surf(X,T,Z) mesh(Z);
%axis([-2 2 0 2 0 2])

Akzeptierte Antwort

Friedrich
Friedrich am 22 Mär. 2013
Bearbeitet: Friedrich am 22 Mär. 2013
Hi,
the problem is that the plot in the book is not really correct. The funtion is a discontinoues function. All points with (x,0) doen't exist and when you plot that in ML you get Inf values at those points which makes the Z axis scales a bit unfortuante.
When you scale the Z axis a bit you can see it gets the shape in the book:
[X,Y] = meshgrid(-2:.1:2 , 0:0.1:2);
Z = (X.^2)./Y;
surf(X,Y,Z)
zlim([0 2])
If you make the stepsize for X and Y smaller you get closer to that image:
[X,Y] = meshgrid(-2:.01:2 , 0:0.01:2);
Z = (X.^2)./Y;
surf(X,Y,Z)
zlim([0 2])

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by