0% found this document useful (0 votes)
4 views14 pages

Lab_01 CA

The ELE-201 Circuit Analysis Laboratory Manual for Spring 2024 introduces students to MATLAB and Multisim for circuit analysis, detailing objectives, equipment, and basic operations. It covers MATLAB functionalities, including variable management, mathematical functions, and plotting techniques, along with lab tasks that involve applying Ohm's Law and analyzing circuits. The manual also includes instructions for verifying results through calculations and simulations.

Uploaded by

Talha Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views14 pages

Lab_01 CA

The ELE-201 Circuit Analysis Laboratory Manual for Spring 2024 introduces students to MATLAB and Multisim for circuit analysis, detailing objectives, equipment, and basic operations. It covers MATLAB functionalities, including variable management, mathematical functions, and plotting techniques, along with lab tasks that involve applying Ohm's Law and analyzing circuits. The manual also includes instructions for verifying results through calculations and simulations.

Uploaded by

Talha Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

ELE-201 Circuit Analysis

LABORATORY MANUAL

CIRCUIT ANALYSIS
(ELE-201)
Semester Spring 2024

Student Name

Student ID

Batch

Lab Instructor:
Engr. Amna Sheikh

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

Index
S. No. Date Objective Sign
Lab 1

Lab 2

Lab 3

Lab 4

Lab 5

Lab 6

Lab 7

Lab 8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13

Lab 14

Lab 15

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

EXPERIMENT 01

OBJECTIVE

To introduce students to MATLAB software and Multisim and familiarize them with its
functions for circuit analysis.

EQUIPMENTS

 Personal Computer (PC)


 MATLAB Software.
 Multisim Software

THEORY
MATLAB is a high-performance language for technical computing. It integrates computation,
visualization and programming environment. Furthermore, MATLAB is a modern programming
language environment: it has sophisticated data structures, contains built in editing and
debugging tools, and supports object-oriented programming.
It has powerful built in routines that enables a very wide variety of computations. It also has easy
to use graphic commands that make the visualization of results immediately available. Specific
applications are collected in packages referred to as toolbox. There are toolboxes for signal
processing, symbolic computation, control theory, simulation, optimization, and several other
fields of applied science and engineering.
This lab is intended to make you familiar with MATLAB
Starting MATLAB
When you start MATLAB, a special window called MATLAB desktop appears. The desktop is a
window that contains other windows. The major tools within or accessible from the desktop are:
Current folder
Command window
Command history
Workspace
Help browser

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

The start screen looks like the one that is shown in Figure 1.

Figure 1.1: The graphical interface to the MATLAB workspace.


Using MATLAB as a Calculator
As an example of a simple interactive calculation, just type the expression you want to evaluate.
For example, let’s suppose you want to calculate the expression, 1 + 2 x 3. You type it at the
prompt command (>>) as follows,
>> 1+2*3
ans = 7

Notice that if you do not specify an output variable, MATLAB uses a default variable answer is
created (or overwritten, if it is already existed). To avoid this, you may assign a value to a
variable or output argument name. For example,
>> x= 1+2*3
x=
7

Will result in x being given the value 1 + 2 x 3 = 7. This variable name can always be used to
refer to the result of the previous computations. Therefore, computing 4x will result in:
>> 4*x
ans = 28.0000

Table 1 gives the partial list of arithmetic operators.


SYMBOL OPERATION EXAMPLE
+ Addition 2+3
- Subtraction 2-3
* Multiplication 2*3
/ Division 2/3

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

Table 1: Basic arithmetic operators.

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

Quitting MATLAB
To end your MATLAB session, type quit in the Command Window, or select File --> Exit
MATLAB in the desktop main menu.
Creating MATLAB Variables
MATLAB variables are with an assignment statement. The syntax of variable assignment is
Variable name = a value (or an expression)
For example
>> x = expression
Where expression is combination of numerical values, mathematical operators, variables.
● Manual entry
● Built in functions
● User defined functions

Overwriting Variable
Once a variable has been created, it can be reassigned. In addition, if you do not wish to see the
intermediate results, you can suppress the numerical output by putting a semicolon (;) at the end
of the line. Then the sequence of commands looks like this:
>> t = 5;
>> t = t+1
t=6

Error Messages
If we enter an expression incorrectly, MATLAB will return an error message. For example in the
following, we left out the multiplication sign , * , in the following expression
>> x = 10;
>> 5x
5x
Error unexpected MATLAB expression.
Making Correction
To make corrections, we can of course retype the expression. But if the expression is lengthy, we
make more mistakes by typing a second time. A previously typed command can be recalled with
the up-arrow key. When the command is displayed at the command prompt, it can be modified if
needed and executed.

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

Controlling the Hierarchy of Operations or Precedence


The order in which MATLAB performs arithmetic operations is exactly that taught in high
school algebra courses.
The order in which arithmetic operations are evaluated is given in Table 2.
PRECEDENCE MATHEMATICAL OPERATION
First The contents of all parentheses are evaluated first, starting
from the innermost parentheses and working outward.
Second All exponentials are evaluated, working from left to right.
Third All multiplication and division are evaluated, working from
left to right.
Fourth All additions and subtractions are evaluated, starting from left
to right.
Table 2: Hierarchy of arithmetic operation.
Managing the Workspace
The content of the workspace persists between the executions of separate commands. Therefore,
it is possible for the results of one problem to have an effect on the next one. To avoid this
possibility, it is good idea to issue a clear command at the start of each new independent
calculation.
>> clear

The command clear or clear all removes all variables from the workspace. This frees up system
memory. In order to display a list of the variables currently in the memory type.
>> who
While, who will give more details which include size, space allocation, and class of the
variables.
Here are few additional useful commands:
To clear the command window, type clc
To abort the MATLAB computation, type ctrl-c.
Getting Help
To view the online documentation, select MATLAB Help menu or MATLAB Help directly in
the Command Window. The preferred method is to use the Help Browser. The Help Browser can
be started by selecting the ? Icon from the desktop toolbar. On the other hand, information about
any command is available by typing.

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

>> help Command

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

Mathematical Function
MATLAB offers many predefined mathematical function for technical computing which
contains large set of mathematical function.
Table 3 Lists some commonly used functions, where variables x and y can be numbers, vectors
or matrices.
COMMAND FUNCTION COMMAND FUNCTION
cos (x) Cosine abs (x) Absolute value
sin (x) Sine sign (x) Signum function
tan (x) Tangent max (x) Maximum value
acos (x) Arc cosine min (x) Minimum value
asin (x) Arc sine ceil (x) Round toward + ∞
atan (x) Arc tangent floor (x) Round toward - ∞
exp (x) Exponential round (x) Round to nearest integer
sqrt (x) Square root rem (x) Remainder after division
log (x) Natural logarithm angle (x) Phase angle
log10 (x) Common logarithm conj (x) Complex conjugate
Table 3: Elementary functions.
In addition to the elementary functions, MATLAB includes a number of predefined constant
values. A list of the most common values is given Table 4.
Pi The π number, π = 3.14159…
ⅈ, j The imaginary unit ⅈ , √ −1
Inf The infinity, ∞
NaN Not a number
Table 4: Predefined constant values.
For example
As a first example, the value of the expression y=e−a sin ( x ) +10 √ y , for a=5 , x=2 and y=8 is
computed by
>> a = 5; x = 2; y = 8;
>> y = exp(-a)*sin(x)+10*sqrt(y)
y= 28.2904

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

Basic Plotting
The simple 2D plotting command include:
COMMAND FUNCTION
Plot Plot in linear coordinates as a continuous function
Stem Plot in linear coordinates as discrete samples
Loglog Logarithmic x and y axes
semilogy Linear y and logarithmic x axes
semilogx Linear x and logarithmic y axes
bar Bar graph
errorbar Error bar graph
Hist Histogram
polar Polar coordinates

Creating Simple Plots


The basic MATLAB graphing procedure, for example in 2D, is to take a vector of x –
Coordinates, x = (x1; . . . . ; xn), and a vector of y-coordinates, y = (y1;. . . . ; yn), locate the
Points (xi; yi), with i = 1; 2; : : : ; n and then join them by straight lines. You need to prepare x
and y in an identical array form; namely, x and y are both row arrays and column arrays of the
same length. The MATLAB command to plot a graph is plot(x,y).
The plot functions has different forms depending on the input arguments. If y is a vector plot(y)
produces a piecewise linear graph of the elements of y versus the index of the elements of y. If
we specify two vectors, as mentioned above, plot(x,y) produces a graph of y versus x.

For example, to plot the function sin (x) on the interval [0; 2π], we first create a vector of x
values ranging from 0 to 2π, then compute the sine of these values, and finally plot the result:

Matrix Operation
In MATLAB, a matrix is a two-dimensional array of numbers. Matrix operations involve
manipulating these arrays to perform mathematical operations.
MATLAB provides a variety of built-in functions for matrix operations, such as matrix addition,
multiplication, and inversion, as well as functions for solving systems of linear equations and
finding eigenvalues and eigenvectors.
Here's an example of how to perform matrix addition in MATLAB:
% define two matrices

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

A = [1 2 3; 4 5 6; 7 8 9];
B = [9 8 7; 6 5 4; 3 2 1];
% add the matrices
C = A + B;
% display the result
disp(C);

Adding Titles, Axis Labels and Annotations


There are many commands used to customize plots by annotations, titles, axes labels, etc. A few
of the most frequently used commands are:

COMMAND FUNCTION
xlabel Labels x-axis
ylabel Labels y-axis
title Puts a title on the plot
grid Adds a grid to the plot
gtext Allows positioning of text with the mouse
Allows placing text at specified coordinates of
text
the plot
axis Allows changing the x and y axes
figure Create a figure for plotting
figure(n) Make figure number n the current figure
Allows multiple plots to be superimposed on
hold on
the same axes
hold off Release hold on current plot
close(n) Close figure number n
Create an a×b matrix of plots with c the
subplot(a,b,c)
current figure
orient Specify orientation of a figure

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

LAB TASK 1

Write a MATLAB script to calculate voltage using Ohm's Law.


Instructions:

 Define the resistance and current values in the circuit (R=10 ohm & I = 0.5:0.1:1 A).
 Calculate the voltage using the formula
 Display the result.
 Verify the result by checking that the voltage is equal to the product of resistance and
current.
 Plot the voltage versus current relationship in a circuit.

Source Code

Code Explanation

Output

LAB TASK 2

Write a MATLAB script to calculate the current through a resistor and power in the circuit using
Ohm's Law and Power Law.
Instructions:

 Define the resistance and voltage values in the circuit (R=100 ohm & V=10 volts).
 Calculate the current and power using the formula
 Display the result using “fprintf” function.

Source Code

Code Explanation

Output

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

LAB TASK 3
Find node voltages in the given network and write code in MATLAB for given network also
verify the result with calculations and Multisim simulation.

Calculations:
MATLAB Code:
Code Explanation:
Output:
Multisim Simulation:
Hardware Picture:

Department of Biomedical Engineering, SHU.


ELE-201 Circuit Analysis

POST LAB TASK 1


Find node voltages in the given network and write code in MATLAB for given network also
verify the result with calculations and Multisim simulation.

Calculations:
MATLAB Code:
Code Explanation:
Output:
Multisim Simulation:

DISCUSSION AND CONCLUSION

Department of Biomedical Engineering, SHU.

You might also like