# 3D graphs - plots and volumes in Matlab

Three-dimensional plots (or 3D graphs) can be created by this numerical software.

Matlab provides many facilities for visualization of 3D information or data (x, y, z). The facilities include built-in functions for plotting wire-frame objects, space-curves, shaded surfaces.

Also, automatic generation of contours, volumetric data display, light sources, interpolation of colors and displaying externally-created images.

Typing ‘help graph3d’ in the command window gives a list of functions available for general 3D graphs.

This is a kind of ‘catalog’ of the most popular 3D graphics functions.

You can use these instructions for your needs simply by following the examples. The ‘meshgrid’ function must be first understood.

Examples:

 t = 0 : .01 : 1; x = 2*t; y = -0.5*t.^2; z1 = t.^3/2; z2 = t.^3/.5; plot3(x,y,z1,'b', x,y,z2,'r') grid x = [0 2.5; 5 2.5; 5 2.5; 0 2.5]; y = [0 0; 0 -1; 0 -1; 0 0]; z = [0 0; 0 0; 2 2; 2 2]; fill3(x,y,z, rand(4,2)) xlabel('x'); ylabel('y'); zlabel('z'); view(120, 50) grid X = -3:.1:3; [x,y] = meshgrid(X,X); z = 1./(3+x.^2+y.^2); contour3(z) xlabel('x'); ylabel('y'); X = -3 : .1 : 3; [x,y] = meshgrid(X,X); z = 1./(3+x.^2+y.^2); surf(z) xlabel('x'); ylabel('y'); X = -3 : .1 : 3; [x,y] = meshgrid(X,X); z = 1./(3+x.^2+y.^2); surfc(z) view(-30,20) xlabel('x'); ylabel('y'); X = -3 : .1 : 3; [x,y] = meshgrid(X,X); z = 1./(3+x.^2+y.^2); surfl(z) shading interp colormap hot xlabel('x'); ylabel('y'); X = -2 : .1 : 2; [x,y] = meshgrid(X,X); z = 5./(1+x.^2+y.^2); mesh(z) xlabel('x'); ylabel('y'); waterfall X = -3 : .1 : 3; [x,y] = meshgrid(X,X); z = -1./(1+x.^2+y.^2); waterfall(z) hidden off xlabel('x'); ylabel('y'); data = [10 23 35 32]; pie3(data) title('Important Data') ribbon x = 0 : .1 : 4*pi; y = cos(x); ribbon(x,y,.1) sphere(45) axis 'equal' z = 0: .03 : 1; r = cos(4*pi*z)+2; cylinder(r)

### Video - Create 3D Images in Matlab

From '3D Graphs' to home

From '3D Graphs' to '3D Plots Menu'

 Top

## Related pages

plot 3d matlab5 color band resistortrapezoidal method exampleohm law chartdefinite integration calculatorloan repayment equationohms law calculatorharmonic series divergesdouble integration calculatorboxplot in matlabseries that converge to piintegral calculaterconvert binary to decimal formulasquare feet to inches calculatorscilab functionsmatlab stdplot gaussian distribution matlableast square fitting matlabletters in asciifibonacci sequence examplevehicle salvage value calculatorhow to solve exponential decay problemsquad matlabcontinuous compounding calculatorlagrange interpolation formula with examplebernoulli calculatorvoltage in rc circuitjordan matricesmatlab gui example codematlab loglogascii code for azdepreciation formula excelgauss jordan elimination c codefactorial in matlabformula for charging capacitorcalculating depreciation with salvage valueinf matlabmatrix manipulation in matlabpolar plotsmatlab fprintf tabledouble factorial calculatorgraphical user interface matlabcompound interest problem solverdivide two polynomialsdecimal ascii chartsalvage value formulaeuclidean algorithm to find gcdzero finder calculatorinterp1 matlabpeak fitting matlabsecond order polynomial fithow to draw a 3d rectangular prismhypotenuse calcrc circuit graphmenu matlabmatlab gui programming bookspascals triangle examplegeomean formulafor loops in matlabmatlab interpolation functionscilab linear regressionintegral calculator with boundsascii char mapconvert from binary to hexadecimalwattage price calculatorsample matlab programsbinary to decimal conversion programmatlab curvefitsalvage value of a carhex to decimal algorithmdraw circle matlab