I need help in developing a function file GE_m(A,b) to determine the pivot row r such that a(rk) is the first nonzero entry among a(kk),a(k+1)...a(n,k). if a(kk)=a(k+1,k)=a(nk)=0 then pivot out that 'A is not invertible' and quit.

1 vue (au cours des 30 derniers jours)
%I need help in developing a function file GE_m(A,b) to determine the pivot row r
% such that a(rk) is the first nonzero entry among a(kk),a(k+1)...a(n,k).
% if a(kk)=a(k+1,k)=a(nk)=0 then pivot out that 'A is not invertible' and quit.
% this is the other function i will be calling in my comand window and this function is correct
%function x=ut_sys(U,c)
%n=length(U);
%x=zeros(n,1);
%x(n)=c(n)/U(n,n);
%for i=n-1:-1:1
% s=0;
% for j=n:-1:i+1
%s =s+U(i,j)*x(j);
% end
% x(i) = (c(i)-s) /U(i,i);
%end
%end
% i need help with the function below!! i cannot get it working
function [A,b]=GE_m(A,b)
n =length(b);
for k=1:n-1
ap=abs(A(k,k));
r=k;
while ap < (n)*e-15
r=r+1;
end
end
if ap , (n)*e-15
disp('A is not invertible');
end
end

Réponse acceptée

Ayush Gupta
Ayush Gupta le 17 Sep 2020
The following problem can be solved by using nested for loop. Refer to the following code to see how to solve this:
function [A,b]=a1(A,b)
n =length(b);
flag = 0;
for k=1:n-1
for i = k:n-1
if(a(k,i) ~= 0)
flag = 1;
end
end
end
if(flag == 1)
disp('A is not invertible')
end
end

Plus de réponses (0)

Catégories

En savoir plus sur Special Functions dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by