signals in matlab

11
Signal in MATLAB 08/29/20 22 DOES - PC

Upload: esys-india-malegaon

Post on 17-May-2015

503 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Signals in matlab

Signal in MATLAB

04/12/2023

DOES - PC

Page 2: Signals in matlab

>> y = sin(linspace(0,2*pi,10));>> stem(y)

1 2 3 4 5 6 7 8 9 10-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

Sine Wave:

0 1 2 3 4 5 6 7-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

x = 0:2

Sin

e of

x

Plot of the Sine Function

>> x = 0:pi/100:2*pi;

>> y = sin(x);

>> plot(x,y)

OR

Page 3: Signals in matlab

>> y = cos(linspace(0,2*pi,10));>> stem(y)

Cosine Wave:

1 2 3 4 5 6 7 8 9 10-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

0 1 2 3 4 5 6 7-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

x = 0:2

Sin

e of

x

Plot of the Sine Function

>> x = 0:pi/100:2*pi;

>> y = sin(x);

>> plot(x,y)

OR

Page 4: Signals in matlab

Multiple Signals:

>> x = 0:pi/100:2*pi;>> y = sin(x);>> y2 = sin(x-.25);>> y3 = sin(x-.5)>> plot(x,y,x,y2,x,y3)

0 1 2 3 4 5 6 7-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

Page 5: Signals in matlab

Multiple Plots:

t = 0:pi/100:2*pi;y1=sin(t);y2=sin(t+pi/2);subplot(2,2,1)plot(t,y1)subplot(2,2,2)plot(t,y2);subplot(2,2,3)plot(t,y1)subplot(2,2,4)plot(t,y2);

0 2 4 6 8-1

-0.5

0

0.5

1

0 2 4 6 8-1

-0.5

0

0.5

1

0 2 4 6 8-1

-0.5

0

0.5

1

0 2 4 6 8-1

-0.5

0

0.5

1

Page 6: Signals in matlab

Square Wave Wave:

0 50 100-1

-0.5

0

0.5

1

Time

Am

plitu

de

Squarewave

0 50 100-1

-0.5

0

0.5

1

Time

Am

plitu

de

Square wave

>> t:0:100;>> y=square(2*pi*100*t/100,50);>> plot(t,y)>> stem(t,y)

Page 7: Signals in matlab

Ramp Signal:

0 5 10 15 200

5

10

15

20

sequence

Am

plitu

de

Ramp Signal

0 5 10 15 200

5

10

15

20

sequence

Am

plitu

de

Ramp Signal

> > t:0:20;>> plot(t,t);>> stem(t,t)

Page 8: Signals in matlab

Exponential Signal:

>> t=0:20;>> y2=exp(t);>> plot(t,y2)>> stem(t,y2)

0 5 10 15 200

2

4

6x 10

8

sequence

Am

plitu

de

Exponential Signal

0 5 10 15 200

2

4

6x 10

8

sequence

Am

plitu

de

Exponential Signal

Page 9: Signals in matlab

Impulse Signal:

-2 -1 0 1 20

0.5

1

time

Am

plitu

de

unit impulse signal

-2 -1 0 1 20

0.5

1

time

Am

plitu

de

unit impulse signal

>> t=-2:1:2;>> y=[zeros(1,2),ones(1,1),zeros(1,2)];>> plot(t,y);>> stem(t,y);

Page 10: Signals in matlab

Step Signal:

0 5 10 15 200

0.5

1

1.5

2

No of sequence

Am

plitu

de

Unit step sequence

0 5 10 15 200

0.5

1

No of sequence

Am

plitu

de

Unit step sequence

>> t=0.1:n-1;>> y1=ones(1,n-1);>> plot(t,y1)>> stem(t,y1)

Page 11: Signals 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