Professional Documents
Culture Documents
Program
clc;
clf;
clear;
t=-7:0.001:8
function y=u(t, a, b, A)
for i=1:length(t)
if (a*t(i)+b)>=0 then
y(i)=1*A;
else y(i)=0;
end
end
endfunction
function y=sine(t, a, b)
y=sin(a*t+b)
endfunction
function y=e(t, a, b)
y=exp(a*t+b)
endfunction
y1=u(t,1,-2.5,-1)+u(t,-2,-2,3)
y2=u(t,-1,3,4)+u(t,2,2,2)
y3=sine(t,2,-4)
y4=e(t,0.9,-0.1)
subplot(2,2,1)
plot(t,y1,'*:')
subplot(2,2,2)
plot(t,y2,'*:')
subplot(2,2,3)
plot(t,y3)
subplot(2,2,4)
plot(t,y4)
Output
3.2 Plot the following discrete time signals for n=-5 to 4.
Program
clc;
clf;
clear;
n=-5:1:4
function y=u(n, a, b, A)
for i=1:length(n)
if (a*n(i)+b)>=0 then
y(i)=1*A;
else y(i)=0;
end
end
endfunction
function y=sine(n, a, b)
y=sin(a*n+b)
endfunction
function y=e(n, a, b)
y=exp(a*n+b)
endfunction
y1=e(n,-0.5,1)
y2=sine(n,3,-1)
y3=u(n,3,5,3)+u(n,1,-3,-1)+u(n,-1,0,1)
subplot(2,2,1)
plot2d3(n,y1)
subplot(2,2,2)
plot2d3(n,y2)
subplot(2,2,3)
plot2d3(n,y3)
Output