Question: A pseudocode to solve the matrix equation ax = b is given below. Here, a is an n times n matrix and b is

A pseudocode to solve the matrix equation ax = b is given below. Here, a is an n \times n matrix and b is an n \times 1 vector. Write a Matlab script (you must name it GaussEl.m) that uses this pseudocode to find the vector x.
Note: Your function will be tested for
30.10.2 a =0.170.3,
0.30.210
7.85
b =19.3.(5)
71.4
Make sure that one gets the correct results when they execute the command
x = GaussEl([3,-0.1,-0.2;0.1,7,-0.3;0.3,-0.2,10],[7.85,-19.3,71.4]). You do not need to discuss results or the code on your report; make sure enough comments are available in your script.
FUNCTION [x]= GaussEl(a,b)
n = number of entries in vector b
DOFOR k =1, n-1
DOFOR i = k+1, n factor_= ai,k/ak,k DOFOR j = k+1, n
ai,j = ai,j - factor_ ak,j END DO
bi = bi factor_ bk END DO
END DO
xn = bn/an,n
DOFOR i = n-1,1,-1
sum_= bi
DOFOR j = i+1,n
sum_= sum_- ai,j xj END DO
xi = sum_/ai,i END DO
END GaussEl

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!