Question: Rewrite the function keeping the Matlab language in as few lines as possible. Use functions from matlab's own languages to shorten it. Look for and

Rewrite the function keeping the Matlab language in as few lines as possible. Use functions from matlab's own languages to shorten it.

Look for and mention possible errors in the function.

------------------------------------------------------------------------------------------------------------------

#Function for calculating Ax=b of a square matrix by the Jacobi method

#A=Coefficient matrix; b=Vector of independent terms; p= random start number #maxItr= maximum number of interactions; maxErr = Maximum tolerance calculated by the waste standard criteria

function x= GaussJacobi (A,b,p, maxItr, maxErr) n=lenght (b); x=p; err= Inf; itr= 0; while itr maxErr xOld=x; for i=1:n sum=0; for j=1:n if j~=i sum= sum + A(i,j)* xOld(j); end if endfor x(i)= (1/A(i,i))*(b(i)-sum); endfor itr= itr+1 err=abs(b-(A*x)); endwhile

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!