S&S Assignments
S&S Assignments
S&S Assignments
grid on;
//for delayed
%delayed Time delta signal
n1=7;
m=n+n1;
subplot(3,1,2);
plot(m,u);
xlabel('Time t');
ylabel('Magnitude of function');
title('Continuous Time delta function');
grid on;
//for advanced
%Advanced Time delta signal
n1=-7;
m=n+n1;
subplot(3,1,3);
plot(m,u);
xlabel('Time t');
ylabel('Magnitude of function');
title('Continuous Time delta function');
grid on;
//FOR discrete
%for dicrete time interval
Q3) solution:
//For continuous
%RAMP function signal
n=-10:10;
u = [zeros(1,10) ones(1,11)];
r= n.*u;%ramp signal
subplot(211);
plot(n,r);
xlabel('Time t');
ylabel("ramp functionb amplitude");
title("continous ramp signal");
grid on;
//For discrete
subplot(212);
stem(n,r);
xlabel('discreate time n');
ylabel('amplitude of ramp signal');
title("Discreate rmap signal");
grid on;
Q4) solution:
//continuos signal
% Continuous Signum Function
t_cont = linspace(-5, 5, 1000);
signum_cont = sign(t_cont);
subplot(3,1,1);
plot(t_cont, signum_cont, 'LineWidth', 2);
title('Continuous Signum Function');
xlabel('t');
ylabel('sign(t)');
grid on;
subplot(3,1,2);
plot(t_cont, delayed_signum_cont, 'LineWidth', 2);
title('Delayed Signum Function (k = 2)');
xlabel('t');
ylabel('sign(t-2)');
grid on;
subplot(3,1,3);
plot(t_cont, advanced_signum_cont, 'LineWidth', 2);
title('Advanced Signum Function (k = 2)');
xlabel('t');
ylabel('sign(t+2)');
grid on;
//disrcete
% Discrete Signum Function
n_disc = -10:10;
signum_disc = sign(n_disc);
subplot(3,1,1);
stem(n_disc, signum_disc, 'LineWidth', 2);
title('Discrete Signum Function');
xlabel('n');
ylabel('sign(n)');
grid on;
subplot(3,1,2);
stem(n_disc, delayed_signum_disc, 'LineWidth', 2);
title('Delayed Signum Function (k = 3)');
xlabel('n');
ylabel('sign(n-3)');
grid on;
subplot(3,1,3);
stem(n_disc, advanced_signum_disc, 'LineWidth', 2);
title('Advanced Signum Function (k = 3)');
xlabel('n');
ylabel('sign(n+3)');
grid on;
Q5) solution
//SAWTOOTH
//delayed
%triangular waveform
T= 10*(1/50);
Fs=1000;
dt=1/Fs;
t= 0:dt:T-dt;
%assigning value
a = t +9;
x=sawtooth(2*pi*50*t,0.5);
subplot(2,1,1);
plot(a,x);
xlabel('t/rightarrow');
ylabel('x');
title("triagular delayed function signal waves");
grid on;
subplot(2,1,2);
stem(a,x);
xlabel('t/rightarrow');
ylabel('x');
grid on;
title("triangular delayed function signal waves");
//Advanced
%triangular waveform
T= 10*(1/50);
Fs=1000;
dt=1/Fs;
t= 0:dt:T-dt;
%assigning value
a = t -9;
x=sawtooth(2*pi*50*t,0.5);
subplot(2,1,1);
plot(a,x);
xlabel('t/rightarrow');
ylabel('x');
title("triagular delayed function signal waves");
grid on;
subplot(2,1,2);
stem(a,x);
xlabel('t/rightarrow');
ylabel('x');
grid on;
title("triangular delayed function signal waves");
Q6)sampling function
%sampling function continous discrete
A=1;F=2;theta=0;
dt=0.001;
t=0:dt:1;
x_1 = A*sin(2*pi*F*t+theta);
subplot(3,1,1);
plot(t,x_1);
xlabel("Time t");
ylabel('x_1');
subtitle("continuos sinal of sampling function",'LineWidth',5);
grid on;
F_s=6*F;T_s=1/F_s;
n=F_s;
n_1 = 0:T_s:n*T_s;
x_2 =A*sin(2*pi*F*n_1+theta);
subplot(3,1,2);
stem(n_1,x_2);
xlabel("Time t");
ylabel('x_2');
subtitle("Discreate sinal of sampling function",'LineWidth',5);
grid on;
//delayed
%sampling function continous discrete
A=1;F=2;theta=0;
dt=0.001;
t=0:dt:1;
%assining values
a = t+9;
x_1 = A*sin(2*pi*F*a+theta);
subplot(3,1,1);
plot(a,x_1);
xlabel("Time t");
ylabel('x_1');
subtitle("continuos sinal of sampling function",'LineWidth',5);
grid on;
F_s=6*F;T_s=1/F_s;
n=F_s;
n_1 = 0:T_s:n*T_s;
b = n_1+9;
x_2 =A*sin(2*pi*F*b+theta);
subplot(3,1,2);
stem(b,x_2);
xlabel("Time t");
ylabel('x_2');
subtitle("Discreate sinal of sampling function",'LineWidth',5);
grid on;
//Advanced
F_s=6*F;T_s=1/F_s;
n=F_s;
n_1 = 0:T_s:n*T_s;
b = n_1-9;
x_2 =A*sin(2*pi*F*b+theta);
subplot(3,1,2);
stem(b,x_2);
xlabel("Time t");
ylabel('x_2');
subtitle("Discreate sinal of sampling function",'LineWidth',5);
grid on;
Q2) unit function
//discrete
n = -10:20; % Range of values for n
unit_step = @(n) (n >= 0);
% Generate delayed unit step function (delayed by 9 units)
delayed_step = @(n, k) unit_step(n - k);
advanced_step = @(n, k) unit_step(n + k);
figure;
subplot(3,1,1);
stem(n, unit_step(n), 'LineWidth', 2);
title('Unit Step Function');
xlabel('n');
ylabel('u(n)');
grid on;
subplot(3,1,2);
stem(n, delayed_step(n, 9), 'LineWidth', 2);
title('Delayed Unit Step Function (k = 9)');
xlabel('n');
ylabel('u(n-9)');
grid on;
subplot(3,1,3);
stem(n, advanced_step(n, 9), 'LineWidth', 2);
title('Advanced Unit Step Function (k = 9)');
xlabel('n');
ylabel('u(n+9)');
grid on;
//Adavanced
% Generate a unit step function
n = -10:20; % Range of values for n
unit_step = @(n) (n >= 0);
subplot(3,1,1);
stem(n, unit_step(n), 'LineWidth', 2);
title('Unit Step Function');
xlabel('n');
ylabel('u(n)');
grid on;
subplot(3,1,2);
stem(n, delayed_step(n, 9), 'LineWidth', 2);
title('Delayed Unit Step Function (k = 9)');
xlabel('n');
ylabel('u(n-9)');
grid on;
subplot(3,1,3);
stem(n, advanced_step(n, 9), 'LineWidth', 2);
title('Advanced Unit Step Function (k = 9)');
xlabel('n');
ylabel('u(n+9)');
grid on;
subplot(3,1,1);
plot(n, unit_step(n), 'LineWidth', 2);
title('Unit Step Function');
xlabel('n');
ylabel('u(n)');
grid on;
subplot(3,1,2);
plot(n, delayed_step(n, 9), 'LineWidth', 2);
title('Delayed Unit Step Function (k = 9)');
xlabel('n');
ylabel('u(n-9)');
grid on;
subplot(3,1,3);
plot(n, advanced_step(n, 9), 'LineWidth', 2);
title('Advanced Unit Step Function (k = 9)');
xlabel('n');
ylabel('u(n+9)');
grid on;
sgtitle('612209029');