(( Only Solve Part D )) Use the following iteration-based methods, using Matlab,
ID: 3767767 • Letter: #
Question
(( Only Solve Part D ))
Use the following iteration-based methods, using Matlab, to approximate the solution of the above system. After each iteration the program should check to see if the convergence condition, below, is satisfied for each equation: The integration-based methods to be considered are the following: Gauss Method Gauss-Seidel method Part C is canceled because numerical analysis using Newton-Raphson method was not covered in class Optional (for extra credit) Gauss-Seidel method with acceleration factor (from 1.1 to 1.8)Explanation / Answer
% Gauss Siedal Method
for j=1:1:size
stringInput = ('Enter the matrix for the solution ');
SolMat = input(stringInput);
emd % end of for loop
len = length(SolMat);
ZeroVect = zeros(len,1);
unitVect = ones(len,1);
% test whether the matrix satisfies the property of dominance along the main diagonal
for indexVar1 = 1:len
indexVar2 = 1:len;
indexVar2(indexVar1) = [ ];
AbsVal = abs(matrixOne(indexVar1,indexVar2));
Check(inedxVar1,1) = abs(matrixOne(indexVar1,indexVar1)) - sum(SolMat);
% compare the diagonal value with the remaining row value
if Check(indexVar1) < 0
disp 'The diagonal dominancy property is not satisfied by this matrix'
end
end
repeat = 0;
while (max(unitVect) > C_n % look for errors
repeat = repeat + 1;
RemembMat = ZeroVect;
for indexVar1 = 1:len
indexVar2 = 1:len; % co efficients here
indexVar2(indexvar1) = [ ];
tempZeroMat = ZeroVect;
tempZeroMat(indexVar1) = [ ];
ZeroVect(inedxVar1,1) = (SolMat(indexVar1,1) - sum(matrixOne(indexVar1, indexVar2) * tempZeroMat)) / matrixOne(indexVar1, indexVar1);
end % end for
SolZeroMat = ZeroVect;
unitVect = sqrt((ZeroVect - RemembMat).^2);
end
SolZeroMat
repeat
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.