S&S Assignments

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 19

Q1) Solution:-

//For continuous impulse function


%Generating Impulse wave(continous)
n = -10:10;
u = [zeros(1,10) 1 zeros(1,10)];
subplot(3,1,1);
plot(n,u);
subtitle('612209037 Aditya Shinde');
xlabel('Time t');
ylabel('Magnitude of function');
title('Continuous Time delta function');

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

subtitle('612209037 Aditya Shinde’);


n = -10:10;
u = [zeros(1,10) 1 zeros(1,10)];
subplot(3,1,1);
stem(n,u);
xlabel("Discreate time n");
ylabel("Magnitude of function");
title('Graph for discrete time impulse signal');
grid on;

%delayed Time delta signal


n1=7;
m=n+n1;
subplot(3,1,2);
stem(m,u);
xlabel('Time t');
ylabel('Magnitude of function');
title('Discrete Time delta function');
grid on;
%advanced Time delta signal
n1=-7;
m=n+n1;
subplot(3,1,3);
stem(m,u);
xlabel('Time t');
ylabel('Magnitude of function');
title('discrete Time delta function');
grid on;

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);

% Delayed Signum Function (Continuous)


k_delay_cont = 2;
delayed_signum_cont = sign(t_cont - k_delay_cont);

% Advanced Signum Function (Continuous)


k_advance_cont = 2;
advanced_signum_cont = sign(t_cont + k_advance_cont);

% Plot Continuous Signum Function and its Delayed/Advanced Versions


figure;

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;

sgtitle('Continuous Signum Functions');

% Adjust layout for better visibility


set(gcf, 'Position', get(0, 'Screensize'));

//disrcete
% Discrete Signum Function
n_disc = -10:10;
signum_disc = sign(n_disc);

% Delayed Signum Function (Discrete)


k_delay_disc = 3;
delayed_signum_disc = sign(n_disc - k_delay_disc);

% Advanced Signum Function (Discrete)


k_advance_disc = 3;
advanced_signum_disc = sign(n_disc + k_advance_disc);

% Plot Discrete Signum Function and its Delayed/Advanced Versions


figure;

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;

sgtitle('Discrete Signum Functions');

% Adjust layout for better visibility


set(gcf, 'Position', get(0, 'Screensize'));

Q5) solution

//SAWTOOTH

//CONTINOUS & DISCERTE


%SAWTOOTH FUNCTION
T= 10*(1/50);
Fs=1000;
dt=1/Fs;
t= 0:dt:T-dt;
x=sawtooth(2*pi*50*t);
subplot(2,1,1);
plot(t,x);
xlabel('TIME t');
ylabel('x');
title("612209029 Ansh Meshram");
subtitle("Sawtooth function continuous")
grid on;
subplot(2,1,2);
stem(t,x);
xlabel('TIME t');
ylabel('x');
grid on;
title("612209029 Ansh Meshram");
subtitle('Sawtooth function discrete')
//delayed
%SAWTOOTH FUNCTION
T= 10*(1/50);
Fs=1000;
dt=1/Fs;
t= 0:dt:T-dt;
a =t+9;
x=sawtooth(2*pi*50*t);
subplot(2,1,1);
plot(a,x);
xlabel('TIME t');
ylabel('x');
title("612209029 Ansh Meshram");
subtitle("Sawtooth function continuous")
grid on;
subplot(2,1,2);
stem(a,x);
xlabel('TIME t');
ylabel('x');
grid on;
title("612209029 Ansh Meshram");
subtitle('Sawtooth function discrete')
//advanced
a =t-9;
//TRIANGULAR

///continuous and discrete


%triangular waveform
T= 10*(1/50);
Fs=1000;
dt=1/Fs;
t= 0:dt:T-dt;
x=sawtooth(2*pi*50*t,0.5);
subplot(2,1,1);
plot(t,x);
xlabel('t/rightarrow');
ylabel('x');
title("triagular function signal waves");
grid on;
subplot(2,1,2);
stem(t,x);
xlabel('t/rightarrow');
ylabel('x');
grid on;
title("triangular function signal waves");

//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");

Q7)Sinc function graph


%sinc function
%========CONTINUOUS
t =linspace(-10,10);
u = sinc(t);
subplot(2,1,1);
plot(t,u);
grid on;
xlabel('Time');
ylabel('Amplitude');
title("612209029 Ansh Meshram");
%%======Discerte
subtitle('continuous sinc function garph');
subplot(2,1,2);
stem(t,u);
title("612209029 Ansh Meshram");
xlabel('Time');
ylabel('Amplitude');
subtitle('delayed sinc function garph');
grid on;
//delayed
%sinc function
%========CONTINUOUS
t =linspace(-10,10);
%assigning variables for delayed
a =t+9 ;%mis last digits
u = sinc(t);
subplot(2,1,1);
plot(a,u);
grid on;
xlabel('Time');
ylabel('Amplitude');
title("612209029 Ansh Meshram");
%%======Discerte
subtitle('continuous sinc function garph');
subplot(2,1,2);
stem(a,u);
title("612209029 Ansh Meshram");
xlabel('Time');
ylabel('Amplitude');
subtitle('delayed sinc function garph');
grid on;
//advanced

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

%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;
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;

sgtitle('612209029');% Generate a unit step function


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);
% Generate advanced unit step function (advanced by 9 units)
advanced_step = @(n, k) unit_step(n + k);
% Plot the unit step functions
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;
sgtitle('612209029');
% Adjust layout for better visibility
set(gcf, 'Position', get(0, 'Screensize'));
% Adjust layout for better visibility
set(gcf, 'Position', get(0, 'Screensize'));

//Adavanced
% Generate a unit step function
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);

% Generate advanced unit step function (advanced by 9 units)


advanced_step = @(n, k) unit_step(n + k);

% Plot the unit step functions


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;

sgtitle('612209029');% Generate a unit step function


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);

% Generate advanced unit step function (advanced by 9 units)


advanced_step = @(n, k) unit_step(n + k);

% Plot the unit step functions


figure;

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');

% Adjust layout for better visibility


set(gcf, 'Position', get(0, 'Screensize'));

% Adjust layout for better visibility


set(gcf, 'Position', get(0, 'Screensize'));

You might also like