Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have an error in my code needed to get fixed plz provide me the right code Here is my code I used n =

I have an error in my code needed to get fixed
plz provide me the right code
Here is my code I used
n = input('Please Enter the size of the equation system n = ') ;
C = input('Please Enter the elements of the Matrix C ' ) ;
b = input('Please Enter the elements of the Matrix b ' ) ;
dett = det(C)
if dett == 0
print('This system unsolvable because det(C) = 0 ')
else
b = b'
A = [ C b ]
for j = 1:(n-1)
for i= (j+1) : n
mult = A(i,j)/A(j,j) ;
for k= j:n+1
A(i,k) = A(i,k) - mult*A(j,k) ;
A
end
end
end
for p = n:-1:1
for r = p+1:n
x(p) = A(p,r)/A(p,r-1)
end
end
end
% Gauss-Elimination method
for i=j+1:m
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j));
enda = input('Enter the augument matrix:')
[m,n]=size(a);
for j=1:m-1
for z=2:m
if a(j,j)==for i=j+1:m
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j));
enda = input('Enter the augument matrix:')
[m,n]=size(a);
0
t=a(j,:);a(j,:)=a(z,:);
a(z,:)=t;
end
end
end
x=zeros(1,m);
for s=m:-1:1
c=0;
for k=2:m
c=c+a(s,k)*x(k);
end
x(s)=(a(s,n)-c)/a(s,s);
end
disp('Gauss elimination method:');
a
x'
image text in transcribed
image text in transcribed
image text in transcribed
Write a Mattah program to solve a linear system of equations using Gauss Elimination with partial pivoting. Use the gauss_olin. fle from class or posted with this assignment as a start. Write a scriptor test function to show solving the system from problem 1 of this homework using your gaussolin_wpivoting with pivoting Function Savo Reset MATLAB Documentation function(x, causs_chin pivoting, b) - Function - backsub, c) For y sireU,1).111 (5.1) - 01/03.1): 10 (1-1) (1:1) - (1-1,1)>(1); 11 end Code to call your function Reset 1- Input('lease ter the site of the equation system - ') t. inputease enter the lines of the Matrix) trput('mase Enter the elements of the Matrix ) dett - det 51 dett print this systes unsolvable because I - Telse A-IC1 10 for 1 - 1:(n-1) 1n input('Please enter the size of the equation system n'); 2 C = Input('Please enter the elements of the Matrix C); 3 b = input('Please enter the elements of the Matrix b'); 4 dett - det(C) 5 if dette 6 print('This system unsolvable because det(C) - 7 else 8 bb 9 A. [CD] 10 for j = 1:(n-1) 11 for i. (+1) : 12 mult - A(1,3)/A(3,1); 13 for k jin+1 14 A(1,k) = A(1,k). mult A(3,k); 15 A 16 end 17 end 18 end 19 for p - 1:-1:1 20 for p = plin 21 (P) = A(0,r)/A(D.--1) 22 end 23 end 24 end 25 X Gauss-Elimination method 26 for 1-34116 27 a(0,1)-(1,2)-a(3.0)*((1,3)/(3,1)); enda - Input("Enter the augument matrix:') 20 (m,n)-size(a); 10 for 1-1:m-1 31 for 2-2 if a(,1)for 1-1+1:m (1,1)-(1,2)-(1, )*((1,3)/(1.1)); Benda - dnput('Enter the augment matrix 3 [m.nl-size(a); 36 0 Assessment: Run Protest Pretest results are not submitted for grading. To run all the tests and submit the results for grading, click Submit Correct answer? (Pretest) Output argument X" (and maybe others) not assigned during call to "gauss_elim_w_pivoting" Error in Test (line 3) x 0. c) = gauss_elim_w_pivoting(A,b); > Use for loops? (Pretest) > No shortcuts (Pretest) Write a Mattah program to solve a linear system of equations using Gauss Elimination with partial pivoting. Use the gauss_olin. fle from class or posted with this assignment as a start. Write a scriptor test function to show solving the system from problem 1 of this homework using your gaussolin_wpivoting with pivoting Function Savo Reset MATLAB Documentation function(x, causs_chin pivoting, b) - Function - backsub, c) For y sireU,1).111 (5.1) - 01/03.1): 10 (1-1) (1:1) - (1-1,1)>(1); 11 end Code to call your function Reset 1- Input('lease ter the site of the equation system - ') t. inputease enter the lines of the Matrix) trput('mase Enter the elements of the Matrix ) dett - det 51 dett print this systes unsolvable because I - Telse A-IC1 10 for 1 - 1:(n-1) 1n input('Please enter the size of the equation system n'); 2 C = Input('Please enter the elements of the Matrix C); 3 b = input('Please enter the elements of the Matrix b'); 4 dett - det(C) 5 if dette 6 print('This system unsolvable because det(C) - 7 else 8 bb 9 A. [CD] 10 for j = 1:(n-1) 11 for i. (+1) : 12 mult - A(1,3)/A(3,1); 13 for k jin+1 14 A(1,k) = A(1,k). mult A(3,k); 15 A 16 end 17 end 18 end 19 for p - 1:-1:1 20 for p = plin 21 (P) = A(0,r)/A(D.--1) 22 end 23 end 24 end 25 X Gauss-Elimination method 26 for 1-34116 27 a(0,1)-(1,2)-a(3.0)*((1,3)/(3,1)); enda - Input("Enter the augument matrix:') 20 (m,n)-size(a); 10 for 1-1:m-1 31 for 2-2 if a(,1)for 1-1+1:m (1,1)-(1,2)-(1, )*((1,3)/(1.1)); Benda - dnput('Enter the augment matrix 3 [m.nl-size(a); 36 0 Assessment: Run Protest Pretest results are not submitted for grading. To run all the tests and submit the results for grading, click Submit Correct answer? (Pretest) Output argument X" (and maybe others) not assigned during call to "gauss_elim_w_pivoting" Error in Test (line 3) x 0. c) = gauss_elim_w_pivoting(A,b); > Use for loops? (Pretest) > No shortcuts (Pretest)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

2. Why has the conflict escalated?

Answered: 1 week ago

Question

1. What might have led to the misinformation?

Answered: 1 week ago