You are on page 1of 46

EXPERIMENT 1:-

# AIM :- Introduction to MATLAB and it's Tools.


# SOFTWARE USED :- MATLAB
# THEORY :-
What is MATLAB?
● Is a high-performance language
● Stands for Matrix Laboratory
● Can be used as a fancy calculator
● Allows you to easily work with entire matrices rather than one number
at a time
● Is useful for anything that requires matrix and vector manipulations
such as:
o Mathematical, scientific, engineering, statistical and financial
problems.
o Anything that requires plotting/visualizing and analysing data.
● Comes with a basic set of tools for visualizing data and for performing
calculations on matrices and vectors
o For specific technologies, MATLAB provides toolboxes, which
add to the basic MATLAB functionality. We have the Image
Processing Toolbox. Some other toolboxes include:
▪ Statistics Toolbox
▪ Neural Network Toolbox
▪ Fuzzy Logic Toolbox
▪ Signal Processing Toolbox
▪ Wavelet Toolbox
▪ Financial Toolbox
▪ Bioinformatics Toolbox
Details about MATLAB Screen :-
The Matlab screen mainly include 4 Parts:- Command Window, Workspace
window, Command History window and Current Directory window.
⮚ COMMAND WINDOW :-

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.

⮚ COMMAND HISTORY WINDOW :-

This is where past commands are remembered. If you want to re-run a


previous command or to edit it you can drag it from this window to the
command window or double click to re-run it.

⮚ COMMAND DIRECTORY WINDOW :-


Details about Toolboxes :-
1. CURVE FITTING :- The Curve Fitting Toolbox for use with MATLAB provides a
user interface and command line functionality for previewing and
preprocessing, as well as creating, comparing, analysing and managing
models.
2. OPTIMIZATION :- Optimization Toolbox is software that solves linear,
quadratic, conic, integer, multiobjective, and nonlinear optimization
problems.
3. PID TUNER :- open PID Tuner for PID tuning . This MATLAB function launches
the PID Tuner app and designs a controller of type for plant sys.
4. ANALOG INPUT RECORDER :- Acquire and visualize analog input signals The
Analog Input Recorder provides a graphical interface to data acquisition
devices.
5. ANALOG OUTPUT GENERATOR :- Define and generate analog output signals
The Analog Output Generator provides a graphical interface to data
acquisition devices.
6. MODBUS EXPLORER :- Read and write to Modbus coils and registers. The
Modbus Explorer enables you to read and write to registers through
Instrument Control Toolbox without having to write a MATLAB script.
7. SYSTEM IDENTIFICATION :- System Identification Toolbox can be used to
create linear and nonlinear dynamic system models from measured time-
domain and frequency-domain input-output data.
8. WIRELESS WAVEFORM GENERATOR :- Create, impair, visualize, and
export modulated waveforms The Wireless Waveform Generator app enables
you to create, impair, visualize, and export modulated waveforms.
9. SIGNAL ANALYZER :- Visualize and compare multiple signals and spectra The
Signal Analyzer app is an interactive tool for visualizing, preprocessing,
measuring, analysing, and comparing signals in the time domain, in the
frequency domain, and in the time-frequency.
10. IMAGE ACQUISITION :- Image Acquisition Toolbox provides a complete set of
tools for controlling and communicating with a variety of PC compatible image
acquisition hardware.
11. INSTRUMENT CONTROL :- Instrument Control Toolbox provides functions
for connecting MAT LAB to a wide variety of test and measurement
equipment. You can acquire data directly into MATLAB for analysis and
visualization.
12. SIMBIOLOGY :- SimBiology provides an app and programmatic tools to
model, simulate, and analyse dynamic systems, focusing on quantitative
systems pharmacology (QSP), physiologically-based pharmacokinetic (PBPK).
13. SIMBIOLOGY MODEL ANALYZER :- Analyse QSP, PK/PD, and mechanistic
systems biology models. The SimBiology Model Analyzer app lets you analyse
models of dynamic systems such as metabolic networks, signalling pathways,
quantitative systems pharmacology (QSP) models.
14. MATLAB CODER :- MATLAB Coder generates portable and readable C and
C++ code from MATLAB code for a variety of hardware platforms, from
desktop systems to embedded hardware.
15. APPLICATION COMPILER :- Package MATLAB programs for deployment as
standalone applications. The Application Compiler app packages MATLAB
programs into applications that can run outside of MATLAB.
16. CLASSIFICATION LEARNER :- Train models to classify data using supervised
machine learning The Classification Learner app trains models to classify data.
17. DEEP NETWORK DESIGNER :- Design, visualize, and train deep learning
networks The Deep Network Designer app lets you build, visualize, edit, and
train deep learning networks.
18. EXPERIMENT MANAGER :- Design and run experiments to train and compare
deep learning networks The Experiment Manager app enables you to create a
deep learning experiment to train networks under various initial conditions
and compare the results.
19. NEURAL NET CLUSTERING :- Cluster data by training a self-organizing maps
network The Neural Net Clustering app leads you through solving a clustering
problem using a self-organizing map (SOM).
20. NEURAL NET FITTING :- Fit data by training a two-layer feedforward network
The Neural Net Fitting app leads you through solving a data-fitting problem
using a two-layer feed-forward network.
21. NEURAL NET TIME SERIES :- Solve a nonlinear time series problem by
training a dynamic neural network. The Neural Net Time Series app leads
you through solving three different kinds of nonlinear time series
problems using a dynamic network.
22. REGRESSION LEARNER :- Train regression models to predict data using
supervised machine learning The Regression Learner app trains
regression models to predict data.
23. DISTRIBUTION FITTER :- Fit probability distributions to data. The
Distribution Fitter app interactively fits probability distributions to data
imported from the MATLAB workspace.
24. PDE MODELER :- Create complex 2-D geometries by drawing,
overlapping, and rotating basic shapes The PDE Modeler app provides
an interactive interface for solving 2-D geometry problems.
25. CONTROL SYSTEM DESIGNER :- Design single-input, single output
(SISO) controllers The Control System Designer app lets you design
single-input, single-output (SISO) controllers for feedback systems
modelled in MAT LAB or Simulink (requires Simulink Control Design
software).
26. DIAGNOSTIC FEATURE DESIGNER :- Interactively extract, visualize, and
rank features from measured or simulated data for machine diagnostics
and prognostics. The Diagnostic Feature Designer app allows you to
accomplish the feature design portion of the predictive maintenance
workflow using a multifunction.
Unit Step Signal In Discrete Time -- Yash Bansal LE

Unit Step Signal In Discrete Time -- Yash Bansal LE

Ramp Signal In Continuous Time -- Yash Bansal LE


EXPERIMENT 2:-
# AIM :- Generation of signals such as Step,
Ramp, Impulse, Sine, Cosine, Exponential,
Parabolic signals .
# SOFTWARE USED :- MATLAB
# THEORY :-
Unit step signal : The step signal or sap junction is that type of standard signal
Which exists only for positive time and its zero for negative time. The unit step
signal has unit magnitude, so that’s why it is known as unit step signal, or unit
step junction.

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.

Sine signal : A sine wave or sinusoidal wave is a mathematical curve defined in


terms of the sine trigonometric function. A sine wave is a special term of signal
because a pure sine wave consists of a single frequency.

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.

Exponential signal : An exponential signal or an exponential function is a


function that represents an exponentially increasing or decreasing series.

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 :-

Ramp Signal In Discrete Time -- Yash Bansal LE

Unit impulse Signal In Discrete Time -- Yash Bansal LE

Unit impulse Signal In Discrete Time -- Yash Bansal LE


#MATLAB PROGRAMS :-

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

Ramp signal in continuous time : Ramp signal in discrete time :

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

Sine signal in continuous time : Sine signal in discrete time :

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

Exponential signal in continuous Exponential signal in discrete time :


time :
clc;
clc; clear all;
clear all; t = 0:1/4:10;
t = 0:1/4:10; A = 1;
A = 1; alpha = 0.5;
alpha = 0.5; y = A*exp(alpha * t);
y = A*exp(alpha * t); stem(t, y);
plot(t, y); xlabel('Time(t)');
xlabel('Time(t)'); ylabel('Amplitude');
ylabel('Amplitude'); title('Exponential signal in discrete
title('Exponential signal in continuous time -- YASH BANSAL LE');
time -- YASH BANSAL LE);
Parabolic signal in continuous time : Parabolic signal in discrete time :

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

Circular Convolution: It is the convolution of two periodic functions that have


same period we can represent it as y(n) = x(n) h(n).
# OUTPUTS :-
Linear Convolution :
# MATLAB PROGRAMS :-
a) Linear Convolution :
clc;
clear all;
x = [1 2 3 4];
y = [1 2 2 1];
z = conv(x,y);
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]);
Circular Convolution :
b) Circular Convolution :

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.

# SOFTWARE USED :- MATLAB R2020a


# THEORY :-
Using KVL and assuming that the currents leaving a node are

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

# SOFTWARE USED :- MATLAB R2020a


# THEORY :-BY USING MESH ANALYSIS
I1= 77/168
I2=16/81
I3=19/81

I through 5 ohm resistor = I3-I2


I=0.037 A

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

# SOFTWARE USED :- MATLAB R2020a


# THEORY :-
TRANSIENT RESPONSE SERIES RLC
When there is a step change (or switching) in a circuit with
capacitors and inductors
together, a transient also occurs. With some differences:
* Energy stored in capacitors (electric fields) and inductors
(magnetic fields) can trade back
and forth during the transient, leading to possible “ringing”
effects.
* The transient waveform can be quite different, depending on
the exact relationship of the
values of C, L, and R.

STEADY STATE RESPONSE


@ The values of voltage and current after which transient
response has died
out is known as steady state response .

@ 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.

You might also like