Question

IN MATLAB a function that performs guassian elimination without partial pivoting. Using matrix size of 1000x1000...

IN MATLAB

a function that performs guassian elimination without partial pivoting. Using matrix size of 1000x1000 with random numbers in the interval [-0.5,0.5]. Initialize the right hand side by computing b = Az with all z values = 1. Use tic and toc to measure execution time.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: If you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc%clears screen
clear all%clears history
close all%closes all files
format long
A=rand(1000,1000)-0.5;
b=A*ones(1000,1);
tic;
z = Gauss_npvt(A, b);
disp('Time taken is');
toc
function x = Gauss_npvt(A, b)
[n, n] = size(A); % Find size of matrix A
[n, k] = size(b); % Find size of matrix b
x = zeros(n,k); % Initialize x
for i = 1:n-1
m = -A(i+1:n,i)/A(i,i); % multipliers
A(i+1:n,:) = A(i+1:n,:) + m*A(i,:);
b(i+1:n,:) = b(i+1:n,:) + m*b(i,:);
end;

% Use back substitution to find unknowns
x(n,:) = b(n,:)/A(n,n);
for i = n-1:-1:1
x(i,:) = (b(i,:) - A(i,i+1:n)*x(i+1:n,:))/A(i,i);
end
end

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
IN MATLAB a function that performs guassian elimination without partial pivoting. Using matrix size of 1000x1000...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT