Generation of Continuous time signals 

% Continuous time Unit step signal 
t=-6:0.1:6;x1=1;x2=0; 
u=x1.*(t>=0)+x2.*(t~=0); 
subplot(2,2,1); 
plot(t,u); 
xlabel('t'); 
ylabel('u(t)'); 
title('Unit Step Signal')

% Continuous time Unit ramp signal 
x1=t; 
r=x1.*(t>=0)+x2.*(t~=0); 
subplot(2,2,2); 
plot(t,r); 
xlabel('t'); 
ylabel('r(t)'); 
title('Unit ramp Signal'); 

% Continuous time Cosine signal 
F=0.5; 
c=cos(2*pi*F*t); 
subplot(2,2,3); 
plot(t,c); 
xlabel('t'); 
ylabel('c(t)'); 
title('Cosine Signal'); 


Generation of discrete time signals 

% Discrete time Unit step signal 
t=-5:0.5:5; 
x1=1; 
x2=0; 
u=x1.*(t>=0)+x2.*(t~=0); 
subplot(2,2,1); 
stem(t,u); 
xlabel('t'); 
ylabel('u(t)'); 
title('Unit Step Signal'); 

% Discrete time Unit ramp signal 
x1=t; 
r=x1.*(t>=0)+x2.*(t~=0); 
subplot(2,2,2); 
stem(t,r); 
xlabel('t'); 
ylabel('r(t)'); 
title('Unit ramp Signal');
% Discrete time Cosine signal 
F=0.5 
t=-2:0.1:2; 
c=cos(2*pi*F*t); 
subplot(2,2,3); 
stem(t,c); 
xlabel('t'); 
ylabel('c(t)'); 
title('Cosine Signal'); 


Basic operations on signals 

% Time shifting operation 
clc 
clear all 
close all 
t=-20:0.001:20; 
x1=1; 
x2=0; 
u=x1.*(t>=0&t<2)+x2.*(t<0&t>2); 
subplot(3,1,1) 
% Plot of Input Signal; 
plot(t,u,'Linewidth',3); 
axis([-20 20 0 2]) 
xlabel('t'); 
ylabel('u(t)'); 
title('input signal u(t)'); 
subplot(3,1,2) 
% Plot of delayed Signal; 
title('u(t-5)'); 
plot(t-5,u,'Linewidth',3); 
axis([-20 20 0 2]) 
xlabel('t'); 
ylabel('u(t-5)'); 
title('time delayed signal u(t-5)'); 
subplot(3,1,3) 
% Plot of advanced Signal; 
title('u(t+5)'); 
plot(t+5,u,'Linewidth',3); 
axis([-20 20 0 2]) 
xlabel('t'); 
ylabel('u(t+5)'); 
title('time advanced signal u(t+5)');


% Amplitude scaling operation 
clc 
clear all 
close all 
t=-20:0.001:20; 
x1=1; 
x2=0; 
u=x1.*(t>=0&t<2)+x2.*(t<0&t>2); % Plot of Input Signal; 
subplot(2,1,1) 
plot(t,u,'Linewidth',3); 
axis([-10 10 0 5]) 
xlabel('t'); 
ylabel('Amplitude'); 
title('input signal u(t)'); 
subplot(2,1,2) 
% Plot of Amplitude shifted Signal; 
plot(t,u+2,'Linewidth',3); 
axis([-10 10 0 5]) 
xlabel('t'); 
ylabel('Amplitude'); 
title('Amplitude shifted signal'); 


%Time Reversal operation 
clc 
clear all 
close all 
t=-20:0.001:20; 
x1=1; 
x2=0; 
u=x1.*(t>=0&t<4)+x2.*(t<0&t>4); % Plot of Input Signal; 
subplot(2,1,1) 
plot(t,u,'Linewidth',3); 
axis([-10 10 0 5]) 
xlabel('t'); 
ylabel('Amplitude'); 
title('input signal u(t)'); 
subplot(2,1,2) % Plot of time reversed Signal; 
plot(-t,u,'Linewidth',3); 
axis([-10 10 0 5]) 
xlabel('t'); 
ylabel('Amplitude'); 
title('Time folded signal u(-t)');