필터 지우기
필터 지우기

I need this program to only output one time. Right now it is outputting for every individual element in the s matrix.

조회 수: 1 (최근 30일)
When I run this program it runs through every single element and has an output for every number in the matrix. How can I make it give one output hwne its run?
function [] = Prgrm1(A,b)
s = rref([A,b]);
s1 = rref(A);
[m,n] = size(s);
s2 = eye(size(s1));
for w=1:m
for q=1:n
if s(:,1:end-1)==s2
disp('Unique Solution');
x=A\b;
disp(x);
elseif (s(w)~=0 || (s(w)==0 && s(q(:,end))==0))
disp('Infinitely Many Solutions');
t=s1(q(:,1:end))>=0
disp('Number of solutions:');
disp(t);
else
disp('No Solution');
end
end
end
end
What I'm getting looks like:
>> Prgrm1([1 0 1; 0 1 1], [1; 1])
Infinitely Many Solutions
t =
logical
1
Number of solutions:
1
Infinitely Many Solutions
t =
logical
0
Number of solutions:
0
Infinitely Many Solutions
t =
logical
0
Number of solutions:
0
Infinitely Many Solutions
t =
logical
1
Number of solutions:
1
No Solution
Infinitely Many Solutions
t =
logical
0
Number of solutions:
0
Infinitely Many Solutions
t =
logical
0
Number of solutions:
0
No Solution
>> Prgrm1([1 0 ; 0 1 ], [1; 1])
Unique Solution
1
1
Unique Solution
1
1
Unique Solution
1
1
Unique Solution
1
1
Unique Solution
1
1
Unique Solution
1
1

답변 (1개)

Payam Morsali
Payam Morsali 2020년 10월 18일
try using ";" after t=s1(q(:,1:end))>=0

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by