How can I make a system identify if a solution has no solutions?

조회 수: 15 (최근 30일)
Jonas Freiheit
Jonas Freiheit 2020년 9월 19일
댓글: Jonas Freiheit 2020년 9월 23일
Hello,
I was wondering how I can make this backsubstitution program identify whether a solution is infinite or has no solutions?
Thank you
function x = backsub(U,b)
if det(A)<=0.000001 %For infinite solution
n = length(b);
syms t
x=sym(zeros(n,1))
x(n)=sym('t')
b=(sym(b))
for i = n:-1:1
x(i)=b(i);
x(n)=sym('t')
if i<n
for j = n:-1:i+1
x(i)=x(i)-A(i,j)*x(j);
end
end
x(i)=x(i)/A(i,i);
end
else %For unique solution
n = length(b);
x = zeros(size(b));
for i = n:-1:1
x(i)=b(i);
if i<n
for j = n:-1:i+1
x(i)=x(i)-A(i,j)*x(j);
end
end
x(i)=x(i)/A(i,i);
x=double(x)
end
end
end

채택된 답변

Keyur Mistry
Keyur Mistry 2020년 9월 22일
I understand you want to identify that the given system has infinite solution or no solution. For the same you can consider using command ‘rank’ on the system matrix ‘U’.
I hope this is useful for you to find the solution.
  댓글 수: 3
Keyur Mistry
Keyur Mistry 2020년 9월 22일
For more clarifiacton rank(U) and rank([U b]) can be compared to check if 'b' is inside the image space of 'U' or not. This is to identify if there is ‘infinite solution’ or ‘no solution’.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by