Draw a Circle in a Three Dimension With Matlab
When I learned about Pie plot and other two dimensional plots in MATLAB (MATLAB 2D plot), first fourth dimension, I was curious to know…
- What are the other types of 2nd plots we can draw in the MATLAB?
- How to write code to draw 2D plot for all those different plot types?
- How to make them more colorful?
I started getting more noesis and doing work on MATLAB R2013a.
I cleared my basic concepts required for plotting unlike 2nd plots. Now I tin draw any second plots with the various available MATLAB functions.
Here I am sharing my experience with the help of this tutorial. You will discover it very interesting plotting different 2D plots and so coloring information technology.
This tutorial is an extension of our previous tutorial of plotting 2d graphs in MATLAB.
Let's swoop in…
Classifications of Two Dimensional Plots in MATLAB
(MATLAB 2D plot)
MATLAB supports more than types of two-dimensional (second) plots. Nosotros are trying to cover plots which are widely used in manufacture and in different projects.
Here is a list of 10 various MATLAB 2d plots.
- Area Plot
- Bar Plot
- Stem Plot
- Stairs Plot
- Barh Plot
- Pie Plot
- Polar Plot
- Compass Plot
- Scatter Plot
- Errorbar Plot
Now, I am describing each 2D plots past using the MATLAB lawmaking and its decorating functions in details.
one. Area Plot
In the Area plotting graph, you can use bones functions. Information technology is a very easy draw.
In the MATLAB plotting, there is a function area() to plot Area.
How to draw Area plot in MATLAB?
Syntax:
The syntax for the Area plot…
surface area(x)
MATLAB Lawmaking:
As an case, we are plotting Area graph for trigonometric office. It is one of the types of functions in MATLAB.
% To create the area plot for the given equation Sin(t)Cos(2t). % Enter the value of range of variable 't'. t=[0:0.two:20]; % Put the given equation a=[sin(t).*cos(2.*t)]; area(a) title('Expanse Plot') Note:
- '%' is used to add the comment. The line starts with '%' will go executed.
- ';' semicolon is used to suppress the entered value.
Output in MATLAB:
After the running code, y'all volition get the Area plot equally shown beneath.
2. Stalk Plot
In Stalk plot, the discrete sequence data and variables are used. This plot is created by using the stem() office.
How to create the Stem plot in MATLAB?
Syntax:
The syntax for the stem plot is,
stem(10) stem(ten, y) stem(----,'colour') stem(----,'width') stem(----,'style')
MATLAB Code:
Here we are creating the stem plot using the MATLAB functions for assortment of some random discrete numbers.
% Consisder the variable range of 'x' and 'y', x=[3 1 6 vii 10 9 11 13 15 17]; y=[fourteen 7 23 11 8 16 9 3 23 17]; stem(ten,y,'r') title('Stem Plot') xlabel('X axis') ylabel('Y centrality') In this program, I used the color part (red 'r') and stem plot function (stem).
To decorate your graph, you can larn more about colour markers and line specifiers in MATLAB.
Output in MATLAB:
You can come across the ii-dimensional stem plot in MATLAB.
three. Bar Plot
You tin create different types of bar plot in MATLAB. Here, I am explaining the simple bar plot lawmaking with the help of multiple functions.
How to draw Bar plot in MATLAB?
Syntax:
The syntax for the bar plot is,
bar(ten,y) bar(x,y,'colourmarkerlinespec')
MATLAB Code:
Let's write a MATLAB code to plot the Bar for arrays of some random numbers.
x=[1 iii 5 7 x xiii 15]; y=[0 0.5 i 1.5 3 ii two]; bar(x,y) title('Bar Plot') xlabel('X axis') ylabel('y centrality') Output in MATLAB:
Below is diagram as bar 2-dimensional plot.
4. Barh Plot
Barh plot is brusque abbreviations of Horizontal bar. Here I am using the Barh part for the horizontal plane.
How to depict a Barh Plot in MATLAB?
Syntax:
The aforementioned syntax uses like bar plot,
barh(x,y) barh(10,y,'colourmarkerlinespec')
MATLAB Code:
x=[ane 3 5 vii ten xiii fifteen]; y=[0 0.five 1 1.5 3 2 2]; barh(x,y) title('Barh Plot') xlabel('10 axis') ylabel('y centrality') Output in MATLAB:
Barh plot is showing in the below diagram.
If you wait at the above graph, you lot can see it the exact 90-caste tilt of Bar graph.
5. Errorbar Plot
Errorbar plot is again of the types of bar plot.
How to draw an Errorbar Plot in MATLAB?
Syntax:
The syntax for the Errorbar plot are,
errorbar(x,y) errorbar(ten,y,'color') errorbar(ten,y','mark') errorbar(x,y,'linespec')
MATLAB Lawmaking:
x=[5 ten 15 20 25 30 35 40]; y=[0.1 3 4 3.5 v 6.six 7 8]; errorbar(x,y,'m') title('Errorbar Plot') xlabel('X axis') ylabel('Y axis') We are adding colour office to decorate our plot.
Output in MATLAB:
See the 2-dimensional mistake plot.
vi. Stairs Plot
This is again one of the MATLAB 2d plots that expect more similar stairs.
How to design the stairs plot in MATLAB?
Syntax:
stairs(ten,y) stairs(x,y,'colourmarkerlinspec')
MATLAB Lawmaking:
Here, I am writing the MATLAB code of stairs plot with the black (k) color function.
x=[0 1 2 4 v 7 8]; y=[1 three four six eight 12 13]; stairs(10,y,'thousand') title('Stairs Plot') xlabel('10 axis') ylabel('Y axis') Output in MATLAB:
Stairs plot is shown in the below diagram. You lot tin design equally per your MATLAB lawmaking.
It more looks like stairs. Isn't it?
vii. Pie Plot
In mathematics, the pie chart is used to indicate data in percentage (%) form.
In MATLAB, you can draw different kinds of pie plots by using simple lawmaking.
How to draw a Pie Plot in MATLAB?
Syntax:
pie(x)
MATLAB Code:
To write the simple code for the pie plot.
x=[ten 20 25 xl 75 80 90]; pie(ten) title('Pie Plot') We have seven numbers in the array 'x'.
When you execute the above code in MATLAB, All the values in assortment gets converted in the percentage.
Output in MATLAB:
If you wait at the lawmaking, we have not added any colour function. By default, Pie plot is colorful. And so it makes plotting Pie graph even easier.
8. Polar Plot
Plotting Polar plot is a little tricky.
When y'all are plotting the polar plot, theta and radius must exist the same size.
How to plot the Polar in MATLAB?
Syntax:
In Polar plot, you can write the following syntax,
polar(theta,radius) polar(theta,radius,'colourmarkerlinspec')
Polar plot role has arguments as theta, radius, line specification.
MATLAB Code:
theta=[-pi/2 pi 2*pi]; radious=[two six 9]; polar(theta,radius,'r--') championship('Polar Plot') Where 'r' considered as the ruby-red color.
Output in MATLAB:
The line specification and color are shown in the below diagram. Red dashed depicts the given radius of the circle [2 six 9].
9. Compass Plot
Compass plot is the same as the polar plot. Both need equal quantities of theta and radius.
How to draw a Compass Plot in MATLAB?
Syntax:
The syntax of the compass plot is,
compass(theta,radius) compass(theta,radius,'colourmarkerlinespec')
MATLAB Code:
For the designing compass plot, you just demand to write only 'compass' role.
theta=[-pi pi/2 pi]; r=[2 6 9]; compass(theta,r,'b--') title('Compass Plot') Output in MATLAB:
10. Scatter Plot
Plotting the scatter plot in MATLAB is unproblematic.
How to describe a Scatter Plot in MATLAB?
Syntax:
For the scatter plot,
scatter(x,y) scatter(x,y,'colourmarkerlinespec')
MATLAB Code:
x=[i 2 3 five 7 9 xi thirteen xv]; y=[i.2 3 4 2.5 3 5.v iv half-dozen seven]; scatter(x,y,'g') title('Scatter Plot') xlabel('Ten axis') ylabel('Y centrality') Output in MATLAB:
After the running MATLAB lawmaking, y'all volition run across this…
There are so many second plots you can describe in MATLAB. I described briefly the nearly useful superlative 10 plots.
In this tutorial, I have covered different types of plots by using examples and different functions [colour |marking way| line spec]. y'all tin read the MATLAB 3D plot with their 5 unlike classifications.
If you lot have any query for MATLAB 2D plot, please annotate below. I will reply to you as soon as possible.
Stay tuned and See yous once again…
I have completed primary in Electrical Power System. I work and write technical tutorials on the PLC, MATLAB programming, and Electrical on DipsLab.com portal.
Sharing my knowledge on this blog makes me happy. And sometimes I delve in Python programming.
hollandwhatumbigh.blogspot.com
Source: https://dipslab.com/matlab-2d-plot-examples/
0 Response to "Draw a Circle in a Three Dimension With Matlab"
Post a Comment