You are on page 1of 4

Lab. No.

07:

Multiplotting in Matlab, more than one graphs on single figure, coloring and representation by
Maths symbols, labels and titles of graphs.
Tools: PC, Matlab

Lab. Objective:

To know about multiplotting and other graphs properties in Matlab

Multiplotting in Matlab

Multiplotting mean how to plot more than one figures on subfigures in a single one figure.

Matlab Code:

%% multiplotting of waveforms%%

t1=0:.001:2*pi;%defining time for first waveform

t2=0:.01:4*pi;%defining time for second waveform

y1=10*cos(2*pi*t1);%defining first waveform

y2=5*tan(2*pi*t2);%defining second waveform

subplot(1,2,1);% Matlab built-inn command for mutiplotting

plot(t1,y1)% plotting first waveform

legend('cosine waveform')

subplot(1,2,2)%Matlab built-inn command for mutiplotting

plot(t2,y2)%plotting first waveform

legend('tangent waveform')
18
x 10
10 1
cosine waveform tangent waveform
8 0

6 -1

4 -2

2 -3

0 -4

-2 -5

-4 -6

-6 -7

-8 -8

-10 -9
0 2 4 6 8 0 5 10 15

Figure 1: Multiplotts on one figire

Multigraphs on one figure

Multigraphs on one figure mean to plot more than one graphs on a single one main figure.

Matlab code:

%% more than one graphs on single figure%%

t=0:.01:2*pi;%defining time for waveform

y1=10*cos(2*pi*t);%defining first waveform

y2=8*asin(4*pi*t);%defining second waveform

plot(t,y1,t,y2)% plotting both of waveforms

legend('cosine waveform','cosecant waveform')

grid on % Built-inn command for lines on graph

15
cosine waveform
cosecant waveform

10

-5

-10
0 1 2 3 4 5 6 7

Figure 2: Many graphs on one figure


Giving color and plotting by mathematical sign

Matlab Code:

%% multiplotting of waveforms%%

t=0:.01:2*pi;%defining time for waveform

y=10*cos(2*pi*t);%defining the waveform

plot(t,y,'k*-')% plotting first waveform with color k and maths symbol *.

legend('cosine waveform')

10
cosine waveform
8

-2

-4

-6

-8

-10
0 1 2 3 4 5 6 7

Figure 3: Coloring of graph

Labels and titles to a graph:

%% more than one graphs on single figure%%

t=-10:.01:10;%defining time for waveform

y1=10*t.^8;%defining the waveform

plot(t,y1)% plotting both of waveform

legend('even waveform')

grid on % Built-inn command for lines on graph

xlabel('time')%labelling x-axis

ylabel('amplitude')%labelling y-axis

title('even waveform')%labelling title


8
x 10 even waveform
10
even waveform
9

amplitude
5

0
-10 -8 -6 -4 -2 0 2 4 6 8 10
time

Figure 4: Labels and titles to a graph

Lab. Assignment:

Plot discrete time unit step function, continuous time decaying exponential and odd waveform on single
figure by sub plotting, add labels, titles, legends and grid on with graphs.

You might also like