0% found this document useful (0 votes)
42 views5 pages

2D Plots: Area (X, F) : Polar Plot

This document provides examples of different types of 2D and 3D plots that can be created in MATLAB, including bar plots, histograms, rose charts, pie charts, stem plots, 3D bar plots, pie plots, stem plots, surface plots, and contour plots. Code examples are given for generating each type of plot using built-in MATLAB plotting functions like bar, hist, rose, pie, stem, bar3, pie3, stem3, mesh, surf, contour, and contour3.

Uploaded by

Mahtab Ghumman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views5 pages

2D Plots: Area (X, F) : Polar Plot

This document provides examples of different types of 2D and 3D plots that can be created in MATLAB, including bar plots, histograms, rose charts, pie charts, stem plots, 3D bar plots, pie plots, stem plots, surface plots, and contour plots. Code examples are given for generating each type of plot using built-in MATLAB plotting functions like bar, hist, rose, pie, stem, bar3, pie3, stem3, mesh, surf, contour, and contour3.

Uploaded by

Mahtab Ghumman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

2D Plots:

Polar plot area(x,f)


>> x=-pi/2:pi/40:pi/2;
>> f=sin(4.*x);
>> Polar(x,f,'r--')

bar(x,f)

bar(f)
>> >> bar(temp,'stacked')
temp=[31,28,24;29,26,22;28,25,20;27,24,16 >> xlabel('months from sept to feb')
;26,22,17;29,25,20]; >> ylabel('temperature in celcius')
>> bar(temp,'group') >> legend('city A','city B','city C')
>> xlabel('months from sept to feb')
>> ylabel('temperature in celcius')
>> legend('city A','city B','city C')

>> x=[0 1 2 3 4 5 6]; Histogram


>> y=[10 15 25 30 35 40 45]; >> x=randn(100,1)*pi;
>> barh(x,y,'g') >> subplot(2,2,1)
>> hist(x)
>> subplot(2,2,2)
>> hist(x,15)
>> p=-2:0.1:2;
>> subplot(2,2,3)
>> hist(x,p)

Rose chart Pie Chart


>> x=randn(100,1)*pi; >> industry=[4 8 20 2 7 10];
>> subplot(2,2,1) >> show=[0 1 0 0 1 0];
>> rose(x) >>
>> subplot(2,2,2) label=({'cement','textile','software','che
>> rose(x,15) mical','telecom','banking'})
>> subplot(2,2,3)
>> p=-2:0.1:2; label =
>> rose(x,p)
'cement' 'textile' 'software'
'chemical' 'telecom' 'banking'

>> pie(industry,show,label);

>> x=-2:0.1:2;
>> y=x.*x;
Complex num plot
>> subplot(1,2,1) >> z=[1+1i 4-8i 20+7i 6+8i 9+2i
>> stairs(x,y,'r--')
>> subplot(1,2,2) 12-4i];
>> stem(x,y,'r--') >> compass(z)
3D Plotting
Plot3
>> t=-4:0.1:4;
>> x=t.^2;
>> y=4*t;
>> plot3(x,y,t,'r--')
>> xlabel('xaxis')
>> ylabel('yaxis')
>> zlabel('zaxis')

Bar3
>> t=-4:0.1:4;
>> x=t.^2;
>> y=4*t;
>> bar3(x,y)
>> bar3(x,y,t)

Bar3h
>> x;
>> y;
>> bar3h(x,y)
Pie3
>>
person=({'Manager','engineer','professor','doctor','architect','desighner'})

person =

'Manager' 'engineer' 'professor' 'doctor' 'architect' 'desighner'

>>
>> strength=[12 15 13 11 6 10];
>> explode=[0 0 1 0 0 1];
>> pie3(strength,explode,person)

Stem3
>> x=linspace(0,6*pi,200);
>> y=x.*cos(x);
>> z=x.*sin(x);
>> stem3(x,y,z)
>> figure(2)
>> stem3(x,y,z,'filled')

Mesh/meshgrid/surf/contour
/contour3
>> [x y]=meshgrid(-1:0.1:2,-2:0.1:2);
>>z=x.^2+y.^2
>> subplot(2,2,1)
>> mesh(x,y,z)
>> subplot(2,2,2)
>> surf(x,y,z)
>> subplot(2,2,3)
>> contour(x,y,z)
>> subplot(2,2,4)
>> contour3(x,y,z)

You might also like