9

Click here to load reader

Plotting graphs in_matlab

Embed Size (px)

DESCRIPTION

Workshop on MATLAB at the Department of Computer Science, Poona College, Pune

Citation preview

Page 1: Plotting graphs in_matlab

-1-0.5

00.5

1

-1

-0.5

0

0.5

10

10

20

30

40

0 1 2 3 4 5 6 7 8 9 100

1

2

3

4

5

6

7

8

9

10

Plotting Graphs in MATLAB

04/12/2023

DOES - PC

Page 2: Plotting graphs in_matlab

2D Plot:Plot(Y)

Plot(Y) plots the columns of Y versus their index if Y is a real number.

Plot(X,Y) If Y is complex, plot(Y) is equivalent to plot(real(Y),imag(Y)).

DOES - PC

Plots: 2D & 3D:

Page 3: Plotting graphs in_matlab

>> x=0:1:10x = 0 1 2 3 4 5 6 7 8 9 10

>> y = 0:10:100y = 0 10 20 30 40 50 60 70 80 90 100

Examples:

Page 4: Plotting graphs in_matlab

0 1 2 3 4 5 6 7 8 9 100

10

20

30

40

50

60

70

80

90

100

>> plot(x,y)

>> plot(x)>> plot(y)

Page 5: Plotting graphs in_matlab

3D Plot:plot3

The plot3 function displays a three-dimensional plot of a set of data points.

DOES - PC

>> t = 0:pi/50:10*pi;>> plot3(sin(t),cos(t),t)

-1-0.5

00.5

1

-1

-0.5

0

0.5

10

10

20

30

40

Page 6: Plotting graphs in_matlab

>> x = [2 2 2 2 2];>> explode = [1 1 1 1 1];>> pie(x,explode)

pie(X)pie(X,explode)

20%

20%

20%

20%

20%

Pie chart (2D):

Page 7: Plotting graphs in_matlab

Pie chart (3D):

>> x = [1 3 0.5 2.5 2]; >> % Create a 3D pie chart using the pie3 function >> figure; >> explode = [0 1 0 0 0]; >> pie3(x, explode);

28%

6%

22%

33%

11%

Page 8: Plotting graphs in_matlab

Graph Functions:

• plot linear plot• stem discrete plot• grid add grid lines• xlabel add X-axis label• ylabel add Y-axis label• title add graph title• subplot divide figure window • figure create new figure window• pause wait for user response

Page 9: Plotting graphs in_matlab

axisBar3GridLineLineSpecLoglogPlotSemilogxSemilogySubplot........

Types of Graphs:

(Use MATLAB help Window)