Graphics in MATLAB | Part 2 - 3D Plotting

3D Plotting

Subplot
Before we start we need to know something about Subplot in MATLAB, in subplot our graph is divided in different screen so that analysis of a graph should be easy.

Function for subplot is given below
>>subplot(a,b,c)
where plot is divided a by b with the position of c.
Let us see an example to clear all that,




3D Plotting
First we will plot sine graph in 3D bar.


 
Here you can see it's a 3D sine graph Plotted on MATLAB


This is Zoom of the graph so that we can see bar section clearly.



In 2d and 3d plot their are similarities in functions, there are some more function also that varies from 2d plot.
Like for a basic 3d plot function in MATLAB is
Plot3(x,y,z) it’s in 3 dimensional then we have to write positions of 3rd dimensions also.
Some functions of 3d plot are-
plot3
stem3

pie3
bar3

Some new functions in MATLAB

Mesh Plot
>> x=magic(50);
>> y=magic(50);
>> z=cat(2,x,y);

>> mesh(z)

Mesh function creates a wireframe in graph.
And colors are given as per height, we can change its color.

meshc
>> x=magic(50);
>> y=magic(50);
>> z=cat(2,x,y);

>> meshc(z)


surf
>> x=magic(50);
>> y=magic(50);
>> z=cat(2,x,y);

>> surf(z)


surfc
>> x=magic(50);
>> y=magic(50);
>> z=cat(2,x,y);

>> surfc(z)


sphere

ellipsoid

For making a cylinder there is a simple function.

>>cylinder

A cylinder will create, you can change property of them.

These are some functions you can try on your MATLAB, these are basic function.

"Try Projection of two balls with different speed on your MATLAB"

Comments