copyable code:
% GaussSeidelR.m
function [x1,ea,iterval] = GaussSeidelR(A,b,omg,esval,max_it)
//if condition
if nargin<2
error('2 arguments');
end
//check the max iteration
if nargin<5||isempty(max_it)
max_it=50;
end
if nargin<4||isempty(esval)
esval=0.00001;
end
if nargin<3||isempty(omg)
omg=1;
end
[m1,n1] = size(A);
if m1~=n1, error('Matrix A '); end
C1 = A;
for i = 1:n1
C1(i,i) = 0; %diagonal
x1(i) = 0;
end
x1 = x1'; %Transpose matrix
for i = 1:n1
C1(i,1:n1) = C1(i,1:n1)/A(i,i);
end
for i = 1:n1
d1(i) = b(i)/A(i,i);
end
iterval = 0;
while iterval<=max_it
xoldval = x1;
for i = 1:n1
x1(i) = d1(i)-C1(i,:)*x1;
x1(i) = omg*x1(i) + (1-omg)*xoldval(i);
if x1(i) ~= 0
ea1(i) = abs((x1(i) - xoldval(i))/x1(i)) * 100;
end
end
iterval = iterval+1;
%while loop
if max(ea1)<=esval
break
end
% iterval
% x1
% ea
end
%main.m
A=[0.8 -0.4 0;-0.4 0.8 -0.4;0 -0.4 0.8]
b=[41;25;105]
esval=0.00001
GaussSeidelR(A,b,1,esval,50)
Problem 12.12 Pls show the m-file Develop your own M-file function for the Gauss-Seidel method without...
Using MATLAB, develop an M-file to determine LU factorization of a square matrix with partial pivoting. That is, develop a function called mylu that is passed the square matrix [A] and returns the triangular matrices [L] and [U] and the permutation P. You are not to use MATLAB built-in function lu in your codes. Test your function by using it to solve a system of equations listed below in part 3. Confirm that your function is working properly by verifying...
I wonder how to solve a problem 3.21 generate asuch that its Develop an M-file function that is passed tw8 sucr vll and returns θ.(c) and the magnitude or(c), and generates three-dimensional plot of the three vectors (a), tb), and with their origins at zero. Use dashed lines for (a) and (b) and a solid line for (c). Test your function for the following vectors nunda n. The first cases to 2 dec- 一0.125. (a) a = [6 4 2];...