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 (최근 30일)
이전 댓글 표시
%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
댓글 수: 0
채택된 답변
Ayush Gupta
2020년 9월 17일
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
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Special Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!