Lab 03: Signals and Sequences: 3.1) Generating Sinusoidal Waveforms

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 8

Signals and Systems Lab DEE,FURC

Lab 03: Signals and Sequences

3.1) Generating sinusoidal waveforms


close all
clear all

% generating sinusoidal waveform for continuous time

W0 = 10.8 % rad/sec
t = -0.5:0.01:0.5;
f = 3.17*cos( W0*t+pi/6);
figure(1)
plot (t,f)
grid
%Debug->save and run

%to change the amplitude to a convergent form

W0 = 10.8 % rad/sec
t = -0.5:0.01:0.5;
f = 3.17*exp(1.3*t).*cos( W0*t+pi/6); % the dot (.)is an scalar which
produces an element by element multiplication
figure(2)
plot (t,f)
grid
%Debug->save and run

Page 1
Signals and Systems Lab DEE,FURC

2.2) Generating discrete exponential waveforms

% alternating discrete exponential sequence

n = -10:1:10
f = 10*(-0.9).^n
figure (3)
stem (n,f)
%for discrete time we use the term 'stem' to view the graph
%whereas for continuous time we used the term'plot'.
grid
xlabel ('sample,n')
ylabel('f(n)')
title('alternatring discrete exponential sequence')
axis([-10,10,-30,30])
text(0,6,'f(n)=10(-0.9).^n')
%Debug->save and run

Page 2
Signals and Systems Lab DEE,FURC

% to view the step function

n = -10:1:10
s= stepfun(n,0)
figure(4)
stem(n,s)
grid
%Debug->save and run

%multiplication of the step function and the discrete waveform we


obtained previously

f1=f.*s
figure(5)
stem(n,f1)
grid
%Debug->save and run

2.3) Time-scaling, shifting and reversal of CT-signal

Page 3
Signals and Systems Lab DEE,FURC

echo off
close all
clear all

% x(t) = (6-t^2)/(2+t^2)
T = 0.001 %sampling time in sec
N = 1024 %number of samples
t = -3*N*T:T:3*N*T %to generate the time axis
x = (6-t.^2)./(2+t.^2);
%if we don't use the dot (.), the terms will consider as matrixes.
figure(1)
plot(t,x)
grid
xlabel('time,seconds')
ylabel('amplitude')
title('x(t) = (6-t^2)/(2+t^2)')

% compressed signal by 4 times

Page 4
Signals and Systems Lab DEE,FURC

x1 = (6-4*t.^2)./(2+4*t.^2);
figure(2)
plot(t,x1)
grid

% expanded signal by 4 times

x2 = (6-(t/4).^2)./(2+(t/4).^2);
figure(3)
plot(t,x2)
grid

%shifting the original signal by 0.5 sec to the right

Page 5
Signals and Systems Lab DEE,FURC

%500*T=0.5
t = -5*N*T:T:5*N*T %changing the time axis to have the whole figure
x = (6-(t-500*T).^2)./(2+(t-500*T).^2);
figure(4)
plot(t,x)
grid

%time-reversal

t = -5*N*T:T:5*N*T
x5 = t.^3;
x6=(-t).^3;
figure(5);
subplot(2,1,1); plot(t,x5); axis([-3,3,-20,20]); grid;
subplot(2,1,2); plot(t,x6); axis([-3,3,-20,20]); grid;

%loading music to test the above properties

Page 6
Signals and Systems Lab DEE,FURC

load handel
Fs =8192
%sound(y,Fs)
Ts=1/Fs;
t1 = -36556*Ts:Ts:36556*Ts
figure(6)
plot(t1,y)

y1=flipud(y)
%sound(y1)
%we need to make the previous sound command to be a command->
%sound(y,Fs)
figure(7)
plot(t1,y1)
grid

%down sampling

m=2

Page 7
Signals and Systems Lab DEE,FURC

z=downsample(y,m) %should use an integer value for m


%sound(z)
%to get the result we should make the terms 'sound(y,Fs)& sound(y1)' as
%command-> %sound(y,Fs)& %sound(y1)

%up sampling

z1=upsample(y,m) %should use an integer value for m


%sound(z1)
%to get the result we should make the terms 'sound(y,Fs)& sound(y1)&
sound(z)'
%as command-> %sound(y,Fs)& %sound(y1)& %sound(z)

Page 8

You might also like