0% found this document useful (0 votes)
36 views13 pages

Experiment 7 MATLAB Mohammad

Uploaded by

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

Experiment 7 MATLAB Mohammad

Uploaded by

lasveofficial
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Experiment 7

Aim: A program to find current in the given circuits, with conditional statements, without,
conditional statements, in Simulink.

Figure 2: Circuit 1 Figure 2: Circuit 2

Apparatus: MATLAB R2023a

Programs and Output:


1. Circuit 1
a. With conditional statements
i. Program:
clc;
clear all;
% Circuit 1- With conditional statements
V= input('Enter dc voltage source(V): ');
R1= input('Enter series resistance(R1): ');
R2= input('Enter shunt resistance(R2): ');
R3= input('Enter load resistance(R3): ');
if (V)&&(R1~=inf)&&(R2)&&(R3~=inf)
RT=R1+(R3*R2)/(R2+R3);
IT=V/RT;
IL=IT*(R2/(R2+R3)); %Load Current is current in R3
disp(['The current in load branch is: ',num2str(IL)]);
elseif ((~R1)&&(~R3))
disp('The current in load branch is infinite')
else
disp('Load Current is equal to zero')
end
ii. Output:

b. Without conditional statements


i. Program:
clc;
clear all;
% Circuit 1- Without conditional statements
V= input('Enter dc voltage source(V): ');
R1= input('Enter series resistance(R1): ');
R2= input('Enter shunt resistance(R2): ');
R3= input('Enter load resistance(R3): ');
% Calculate equivalent resistances for open and short-circuited cases
R2_equiv = 1 / (1 / R2 + 1 / R3);

% Calculate the total current passing through the circuit


I_total = V / (R1 + R2_equiv);

% Calculate the current passing through the load resistance


current_in_load = I_total * (R2 / (R2 + R3));
disp(current_in_load)
ii. Output:

c. In Simulink
i. Circuit Diagram
ii. Outputs of each:
1. Overall Circuit:

2. R2 Branch:
3. R3 Branch:

2. Circuit 2:
a. With conditional statements:
i. Program:
clc;
clear all;
% Circuit 2- With conditional statements
Vrms= input('Enter AC RMS voltage source(V): ');
R1= input('Enter series resistance(R1): ');
R2= input('Enter shunt resistance(R2): ');
R3= input('Enter load resistance(R3): ');
C= input('Enter Capacitor Value(C): ');
L= input('Enter Inductor Value(L): ');
f= input('Enter Supply frequency Value(f): ');

if (Vrms)&&(R1~=inf)&&(R2)&&(R3~=inf)
w = 2*pi*f;
Z1 = R2 + 1j*w*L;
Z3 = (Z1*R3)/[Z1 + R3];
Xc = (-1)/(w*C);
Z2 = (R1*(1j*Xc))/(R1+(1j*Xc));
Z = Z2 + Z3; % Total Impedance Z
It = Vrms/Z; % Let Total Current = It
I3 = It*Z1/[R3 + Z1]; % Current in resistance R3 by Current
Division Rule
disp(['The current in load branch is: ',num2str(I3)]);
elseif (~R1)&&(~R3)
disp('The current in load branch is infinite')
else
disp('Load Current is equal to zero')
end
ii. Output:

b. Without conditional statements:


i. Program:
clc;
clear all;
V= input('Enter ac voltage source(V): ');
f= input('Enter ac voltage source frequency(f): ');
R1= input('Enter series resistance(R1): ');
C1= input('Enter series capacitance(C1): ');
R2= input('Enter shunt resistance(R2): ');
L1= input('Enter shunt inductance(L1): ');
R3= input('Enter load resistance(R3): ');
w=2*pi*f;
Zl=1i*w*L1;
Zc=-1i/(w*C1);
Z1=(Zc*R1)/(Zc+R1);
Zi=R2+Zl;
Z2=(Zi*R3)/(Zi+R3);
Z=Z1+Z2;
It=V/Z;
Il=(It*Zi)/(Zi+R3);
disp(['The current in load branch is: ',num2str(Il)]);
ii. Output:

c. In Simulink:
i. Circuit Diagram:

R1

L1

C1 R3

R2

f(x) = 0

Scope2
ii. Output:
1. Current in Complete Circuit:
2. Current in R1 Branch:
3. Current in R2, L1 Branch:
4. Current in R3 Branch:
5. Current in C1 Branch:
Result: Programs to solve for current in both circuits, with and without conditional
statements and in Simulink are successfully written and executed.

Evaluation:
CRITERIA TOTAL MARKS MARKS OBTAINED COMMENTS

Concept(A) 2

Implementation(B) 2

Performance(C) 2

Total 6

You might also like