banner



How To Draw Rectangle In Matlab

MATLAB Programming Feature image

Did you ever wonder seeing amazing 3D graphs in MATLAB? How to depict multiple 3D plot graphs in MATLAB?

This is an in-depth tutorial for you. I will explain the different MATLAB 3D plot examples and how to describe them.

This tutorial is an extension of a previous tutorial two-dimensional [2nd] MATLAB plot.

When I share the 2D plot graph tutorial, some of the readers asked me about the 3D plot. And I decided to write about it.

This tutorial provides you the plot'southward functions, syntax, and code, for example for the 5 primary unlike types of 3D plots. At the end of this mail service, you will be able to draw your own 3D plot graph in MATLAB.

Information technology's amazing. Right?

Allow's start.

3D MATLAB Plot Introduction

In full general, the three-dimensional plots consist of the three vectors (x,y,z) in the same graph.

In MATLAB, the plot3() function is used to draw the 3D plot graph. You can also use a specified line style, mark, and color for drawing 3D plots.

The general syntax to display the 3D plot is,

plot3(x,y,z)  plot3(x,y,z,Name)  plot3(10,y,z,LineSpec)

Let's offset drawing different types of the 3D plot graph…

 Classifications of Three-Dimensional Plots | MATLAB 3D plot Examples

Hither, we are considering, the five principal different types of three-dimensional (3D) plots. These graphs are more often than not used in the industry.

The following list of  different 3D plots as,

  1. Mesh Plot
  2. Surface Plot
  3. Ribbon PLot
  4. Profile Plot
  5. Slice Plot

Equally a part of this tutorial about MATLAB 3D plot examples, I am describing the topmost v 3D plots one-by-i.

1. Mesh 3D Plot in MATLAB

The mesh plotting office is used to display the mesh plot. It produces a wireframe surface where the lines connecting the defining points are colored.

How to create the Mesh plot in MATLAB?

For the mesh plotting in MATLAB, yous need to laissez passer the assortment values to the mesh office.

Syntax:

Mesh function transforms the domain specified by vectors (X, Y, Z) into arrays (x,y,z).

The syntax for the Mesh Plot is,

mesh(x,y,z) [10,Y,Z] = meshgrid(ten,y,z)

MATLAB Code:

As an instance, we are plotting the mesh 3D plot for square root mathematical function.

[x,y] = meshgrid(-10:0.i:10);  t = sqrt(x.^2+y.^2); z =(10*sin(t)); mesh(ten,y,z)

Output in MATLAB:

See here, you get a colorful and shine connecting surface line of three-dimensional [3D] Mesh plot.

You can also plot the graph for various Mathematical Expressions in MATLAB.

2. Surface 3D Plot in MATLAB

A surface plot is somewhat similar to a mesh plot. The main difference between them is, in the surface plot, the connecting lines and the faces both will be displayed in the dark colour.

How to create the Surf plot in MATLAB?

Syntax:

In the surface plot, 'surf' function is used. So, you can write a elementary format like 'role name(array)'.

surf(ten,y,z)  surf(z)

MATLAB Lawmaking:

Let'due south write a MATLAB lawmaking for the three-dimensional surface plot for an exponential function exp().

[x,y] = peaks(30); z = exp(-0.9*(x.^2+0.v*(ten-y).^2)); surf(10,y,z); xlabel('\bf X axis'); ylabel('\bf Y axis'); zlabel('\bf Z axis'); title('\bf Surface Plot') colorbar

Output in MATLAB:

After the getting output of surface plot, you volition see the connecting lines and the faces are both displayed in the same shade.

3. Ribbon 3D Plot in MATLAB

As the name ribbon, this 3D plot graph will be having different color ribbons.

How to create the ribbon plot in MATLAB?

Here, nosotros are using ribbon() function for plotting ribbon 3D MATLAB plot.

Syntax:

The general syntax for writing code,

ribbon(x,y,z) ribbon(x,y) ribbon(z)

MATLAB Code:

To create a ribbon plot using peak function for mathematical function  ((x²)-(y²))

[10,y] = peaks(thirty); z =[(10.^two)-(y.^ii)]; ribbon(z); title('\bf Ribbon Plot')

Output in MATLAB:

You tin can see each and every colorful shade ribbons.

four. Contour 3D Plot in MATLAB

How to create the three dimensional [3D] contour plot?

To create the 3 dimensional [3D] contour plot, nosotros are using the 'contour3' function.

Annotation: Yous tin can plot the Contour 2nd plot by using the simply 'contour' part.

Syntax:

The syntax for the iii-dimensional contour plot,

contour3(x,y,z) contour3(z)

MATLAB Code:

We are plotting the contour plot for the exponential mathematical equation is (exp( 10²-y²)).

[x,y] = peaks(30); z = exp(-x.^2-y.^2); contour3(ten,y,z); title('\bf Contour Plot')

Output in MATLAB:

Beneath is a diagram for iii dimensional [3D] contour plot.

five. Piece 3D Plot in MATLAB

For plotting slice graph, yous must know volumetric data(v), specification of iii-dimensional coordinate (x,y,z), and 'xslice, yslice, zslice'.

Syntax:

Slice plot'south syntax is

slice(x,y,z,5,xslice,yslice,zslice)  piece(v,xslice,yslice,zslice)

Where,

  • xslice- 'x' coordinate data for slice plot
  • yslice- 'y' coordinate data for slice plot
  • zslice- 'z' coordinate information for slice plot

MATLAB Code:

Slice plot is little dissimilar from other 3D plots types. When you are writing MATLAB code for Slice plot, you need to specify each coordinator value.

Let's draw the slite plot graph for an exponential mathematical equation.

[10,y,z] = meshgrid(-10:.2:x); 5 = [exp((x.^2)-(y.^3)-(z.^v))]; xslice = 0.1;  yslice = 5; zslice = 0; slice(10,y,z,v,xslice,yslice,zslice) colorbar championship('\bf Slice Plot')

Output in MATLAB:

The output looks like the beneath motion picture.

These are the topmost three dimensional  [3D] used in the industry projects.

This is all about different MATLAB 3D plot examples. I have explained the dissimilar nomenclature of MATLAB 3D plots with simple code and syntax.

If y'all accept doubt, write in the annotate. I will reply to y'all equally before long as possible.

Other MATLAB Tutorials:

  • MATLAB Math Functions
  • MATLAB M-File Details
  • Matrix in MATLAB
  • Vector in MATLAB
  • MATLAB/ Simulink Toolbox
  • Application of MATLAB/Simulink

Thanks for Reading!

If You Appreciate What I Do Here On DipsLab, You Should Consider:

DipsLab is the fastest growing and nigh trusted community site for Electrical and Electronics Engineers. All the published articles are available FREELY to all.

If you like what you are reading, please consider buying me a coffee ( or two ) as a token of appreciation.

This will assist me to continue my services and pay the bills.

coffee

I'm thankful for your never-catastrophe support.

Source: https://dipslab.com/matlab-3d-plot-examples/

Posted by: mcneillween1992.blogspot.com

0 Response to "How To Draw Rectangle In Matlab"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel