Professional Documents
Culture Documents
This is where you type commands and usually the outputs (or error messages)
appear here too.
⮚ WORKSPACE WINDOW :-
If you define new variables their names should be listed here.
Unit ramp signal : A ramp junction or ramp signal is a type of standard signal,
which start at (t = 0) and increases linearly with time.
Unit impulse signal : A unit impulse signal is a type of signal which has it’s value
only at origin, and it is unit impulse so it has magnitude one. Unit impulse signal
has value 0 at negative and positive time axis.
Cosine signal : Sine and cosine waves are signal waveforms which are identical
to each other, the main difference between the two is that the cosine wave leads
the sine wave by an amount of 90 degrees.
Parabolic signal : When the signal gives the constant acceleration distinction of
actual input signal, such a signal is known as parabolic signal or parabolic
function. It is also known as unit acceleration signal.
OUTPUTS :-
Unit step signal in continuous time : Unit step signal in discrete time :
clc; clc;
clear all; clear all;
t = -10:0.001:10; t1 = -10:10;
y = zeros(size(t)); x1=[zeros(1,10) ones(1,11)];
for i = 1:length(t) subplot(2,1,[2]);
if t(i) >= 0 stem(t1,x1);
y(i) = 1; xlabel('time(t)');
else ylabel('Amplitude');
y(i) = 0; axis([-10 10 0 2]);
end title('Unit step signal in discrete time -
end - YASH BANSAL LE');
subplot(2, 1, 1);
plot(t, y);
xlabel('Time(t)');
ylabel('Amplitude');
axis([-10 10 0 2])
title('Unit step signal in continuous
time -- YASH BANSAL LE);
clc; clc;
clear all; clear all;
t = -10:10; t = -10:10;
u=[zeros(1,10) ones(1,11)]; u=[zeros(1,10) ones(1,11)];
r = t.*u; r = t.*u;
subplot(2,1,[1]); subplot(2,1,[1]);
plot(t,r); stem(t,r);
xlabel('time(t)'); xlabel('time(t)');
ylabel('Amplitude'); ylabel('Amplitude');
axis([-10 10 0 10]); axis([-10 10 0 10]);
title('Ramp signal in continuous time title('Ramp signal in discrete time --
--YASH BANSAL LE'); YASH BANSAL 0341320721');
Impulse signal in continuous time : Impulse signal in discrete time :
clc; clc;
clear all; clear all;
t = -10:10; t = -10:10;
for i=1:length(t) for i=1:length(t)
if t(i)==0 if t(i)==0
impulse(i)=1; impulse(i)=1;
else else
impulse(i)=0; impulse(i)=0;
end end
end end
subplot(2,1,[1]); subplot(2,1,[1]);
plot(t,impulse); stem(t,impulse);
xlabel('time(t)'); xlabel('time(t)');
ylabel('Amplitude'); ylabel('Amplitude');
axis([-10 10 0 2]); axis([-10 10 0 2]);
title('Unit impulse signal in discrete title('Unit impulse signal in discrete
time --YASH BANSAL LE'); time -- YASH BANSAL LE');
clc; clc;
clear all; clear all;
x = -10:1/100:10; x = -10:1/4:10;
y = sin(x); y = sin(x);
subplot(2,1,[1]); subplot(2,1,[1]);
plot(x,y); stem(x,y);
xlabel('time(t)'); xlabel('time(t)');
ylabel('Amplitude'); ylabel('Amplitude');
axis([-10 10 -2 2]); axis([-10 10 -2 2]);
title('Sine signal in continuous time title('Sine signal in discrete time --
-- YASH BANSAL LE); YASH BANSAL LE');
Cosine signal in continuous time : Cosine signal in discrete time :
clc; clc;
clear all; clear all;
x = -10:1/100:10; x = -10:1/4:10;
y = cos(x); y = cos(x);
subplot(2,1,[1]); subplot(2,1,[1]);
plot(x,y); stem(x,y);
xlabel('time(t)'); xlabel('time(t)');
ylabel('Amplitude'); ylabel('Amplitude');
axis([-10 10 -2 2]); axis([-10 10 -2 2]);
title('Cosine signal in continuous title('Cosine signal in discrete time --
time -- YASH BANSAL LE'); YASH BANSAL LE);
clc; clc;
clear all; clear all;
t = 0:0.001:10; t = 0:1/4:10;
for i = 1:length(t) for i = 1:length(t)
if t(i)>=0 if t(i)>=0
parabolic(i) = 0.5*(t(i)^2); parabolic(i) = 0.5*(t(i)^2);
else else
parabolic(i) = 0; parabolic(i) = 0;
end end
end end
subplot(1, 1, 1); subplot(1, 1, 1);
plot(t,parabolic); stem(t,parabolic);
xlabel('Time(t)'); xlabel('Time(t)');
ylabel('Amplitude'); ylabel('Amplitude');
title('Parabolic signal in continuous title('Parabolic signal in discrete time
time -- Yash Bansal LE'); -- Yash Bansal LE');
# RESULT :-
All the signals are generated in MATLAB in both continuous and discrete time.
EXPERIMENT 3:-
# AIM :-
a) Write a MATLAB program to find linear
convolution between two sequences and verify
its result using matrix method.
b) Write a MATLAB program to find circular
convolution between two sequences and verify
its result using matrix method.
# SOFTWARE USED :- MATLAB
# THEORY :-
Linear Convolution: It is the basic operation to calculate output for any linear
time invariant system given its input and its impulse response. We can represent
linear convolution as y(n) = x(n) h(n).
clc;
clear all;
x = [2 1 2 3];
y = [1 2 3 2];
z = cconv(x,y, 4);
subplot(3,1,1);
stem(x);
xlabel('n1 ----- >');
ylabel('Amplitude');
title('First Sequence – Yash Bansal LE');
axis([0 5 0 15]);
subplot(3,1,2);
stem(y);
xlabel('n2 ----- >');
ylabel('Amplitude');
title('Second Sequence');
axis([0 5 0 15]);
subplot(3,1,3);
stem(z);
xlabel('n3 ----- >');
ylabel('Amplitude');
title('Convolved Output');
axis([0 8 0 20]);
# RESULT :-
The Linear and Circular convolution between two sequences has been
performed and their result is also verified using matrix method.
#MATLAB produces the following result :-
1) Step Response:-
Taranjot SIngh
2)|Impulse Response: -
Taranjot SIngh
EXPERIMENT 4 -
# AIM :- To study time response of linear system.
# SOFTWARE USED :- MATLAB R2020a
# MATLAB Script :-
# EDITOR WINDOW
EXPERIMENT 5:-
# AIM :- Using MATLAB Determine current in
various resistors using Nodal analysis.
positive,we have
V1=404.2875V
V2=250V
V3=412.8571
CODE--
OUTPUT--
# PROCEDURE :
MATLAB Script :-
clc;
clear all;
close all;
Y = [0.15 -0.1 -0.05;
-0.1 0.145 -0.025;
-0.05 -0.025 0.075];
| = [5; 0; 2];
% solve for the voltage
fprintf(‘Nodal voltages V1,
V2 and V3 are \n’)
v = inv(Y)*l ;
# RESULT
From calculation
V1=404.2875V
V2=250V
V3=412.8571
From MATLAB
V1=404.2875V
V2=250V
V3=412.8571
EXPERIMENT 6:-
# AIM :- Using MATLAB determine the power
disssipiated by 50hm resistor Using mesh
analysis
Power
P= I*I*R= 4.7531 Watts
Code-
Output—
# PROCEDURE :
MATLAB Script :-
Z = [40 -10 -30;
-10 30 -5;
-30 -5 65];
V =[1000]'
% solve for the loop currents
| = inv(Z)*V;
% current through RB is calculated
IRB = I(3) - 1(2);
fprintf(‘the current through R is %8.3f Amps \n',IRB)
% the power supplied by source is calculated
PS = 1(1)*10;
fprintf(‘the power supplied by 10V source is %8.4f watts \n',PS)
# RESULT
From calculation
the current through R is 0.037 Amps
the power supplied by 10V source is 4.7531 watts
From MATLAB
the current through R is 0.037 Amps
the power supplied by 10V source is 4.7531 watts
EXPERIMENT 7:-
# AIM :- To study the transient response of series
RLC circuit by
A.Using Matlab code
@ it is represented by Cl.
CODE—
# PROCEDURE :
Using Matlab code
MATLAB Script :-
% Transfer Function Calculation for an AC Circuit
clear all; close all; clc;
% Circuit Parameters
R= 30; % Resistance (30 Ohm)
L= 0.7e-3; % Inductance (0.7 mH)
C= 1.5e-6; % Capacitance (1.5 microfarad)
f= logspace(1,5); % Frequency range between 10 Hz and 100 kHz
omega= 2*pi.*f; % Angular Frequency
ZC= 1./(j.*omega.*C); % Capacitive Reactance
ZL= j.*omega.*L; % Inductive Reactance
Hf=ZC./(ZC+ZL+R); % Transfer Function (VO/V1)
% Plot the phase and the magnitude response of a transfer function
%Magnitude Plot
subplot(211)
%loglog(...) is the same as PLOT(...), except logarithmic scales are used for
both the X- and Y- axes.
loglog(f,abs(Hf))
title( Magnitude’)
xlabel(‘Frequency (Hz)’)
ylabel(‘Amplitude’)
% Please see "help axis" in order to understand how does axis work.
axis([10 1e5 1e-3 10]) % Manual axis adjustment
%Phase Plot
subplot(212)
OUTPUT—
%semilogx(...) is the same as PLOT(...), except a logarithmic (base 10) scale
is used for the X-axis.
semilogx(f,angle(Hf))
title(Phase’')
xlabel(‘Frequency (Hz)’)
ylabel(‘Angle (rad)’)
axis([10 1e5 -3.5 0.5]) % Manual axis adjustment
# RESULT
Transient response of RLC circuit is being performed
and verified.