Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

All submitted assignments will be checked for similarity and plagiarism using an

ID: 2083163 • Letter: A

Question

All submitted assignments will be checked for similarity and plagiarism using an advanced software tool. The University of Sharjah, and the department of Electrical and Computer Engineering take the issue of plagiarism very seriously. Copying from other students or the Internet without proper citation is considered an academic offense. In the case of plagiarism, a penalty will apply and its severity will be based on the percentage of similarity report generated by the plagiarism detection tool, as well as the number of academic offences the student has in the past. Such cases will be escalated to the department chair. Write a program in MATLAB to analyze the circuit of a ladder filter as shown in the circuit below. The circuit contains of n coils, n-1 capacitors, two resistors (R1 and R2) and AC voltage source in the form of V-Vmcos(wt R1 n-1 The following requirements should be fulfilled 1. The minimum number of coils in 3 2. If the number of coils is n the number of capacitors must be n-1. The user will be prompted to enter the correct number of capacitors if it is different from n-1 3. The values of all resistors, coils and capacitors must be real and positive t is required to find the mesh currents based on Ohm's law V J ZI where Vis the supply voltage, Z is the impedance matrix and listhe vector representing the mesh currents The system of equations has to be solved using Gauss-Seidel iterative method, assume the tolerance/error to be less than 0.00001. Calculate the relative error for each current and the significant digit. Sample example 1 (note: The red colour represents the data entered by the user) Enter values of the two resistances in ohm, [R1 R2j [1 100] Enter the inductance values in Henry, L1... nl-[0.10.10.5

Explanation / Answer

%% % Gauss-Seidel Method in MATLAB
clc
clear all
close all
disp ( 'Enter the system of linear equations in the form of V = IR')

%% Inputting parameters
n = input ( 'Enter total number of coils : ')
Vm = input ( 'Enter Voltage : ')
Vphase = input ( 'Enter phase : ')
Freq = input ( 'Enter frequency : ')
R = [];
L = []'
C = [];
while (numel(R) ~=2)
R = input ( 'Enter reistance value R1 and R2 : ');
end

while (numel(L) ~= n)
L = input ( 'Enter the inductance value in henry : ');
end

while(numel(C) ~= n-1)
C = input ( 'Enter capaciatnce value in farads : ')
end

%% Create inductance matrix
mul = 1j*Freq;
I(1,:) = [R(1,1) + mul*L(1,1) + 1/(mul*C(1,1)) -1/(mul*C(1,1)) zeros(1,n-2)];

for temp = 2:n-1
%I(temp,:) = [zeros(1,temp-2) -C(1,temp-1) C(1,temp-1)+C(1,temp)+L(1,temp) zeros(1,n-temp)];
I(temp,:) = [zeros(1,temp-2) -1/(mul*C(1,temp-1)) 1/(mul*C(1,temp-1))+1/(mul*C(1,temp))+mul*L(1,temp) -1/(mul*C(1,temp)) zeros(1,n-1-temp)];
end
I(n,:) = [zeros(1,n-2) -1/(mul*C(1,n-1)) 1/(mul*C(1,n-1))+R(1,2)+mul*L(1,n)];

%% Voltage matrix
V = [Vm*cos(pi*Vphase/180) + 1j*Vm*sin(pi*Vphase/180) zeros(1,n-1)]';

%% gauss_seidel
A = I;
B = V;

% Finding matrix dimensions
[na , ma ] = size (A);
[nb , mb ] = size (B);

% Upper and lower matrix
D = diag(diag(A));
L1 = tril(A)- D;
U = triu(A)- D;

%checking for convergence
e= max(eig(-inv(D+L1)*(U)));
if abs(e) >= 1
disp ('Since the modulus of the largest Eigen value of iterative matrix is not less than 1')
disp ('this process is not convergent.')
return
end


X0 = ones(na,1);
t = input ( 'Enter the error allowed in final answer: ');
tol = t*ones(na,1);
k= 1;
X( : , 1 ) = X0;
err= 1000000000*rand(na,1);% initial error assumption for looping
while sum(abs(err) >= tol) ~= zeros(na,1)
X ( : ,k+ 1 ) = -inv(D+L1)*(U)*X( : ,k) + inv(D+L1)*B;% Gauss-Seidel formula
err = X( :,k+1) - X( :, k);% finding error
k = k + 1;
  
end
fprintf ('The final answer obtained after %g iterations is ', k)
X( : ,k)