"solve" bug?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello everyone, I am writing because I have a problem with the resolution of inequality.
syms x;
f = 6*x + 24;
s = solve(f < 0, x, 'Real', true)
This is the result:
s =
-5
I have tried everything to fix it. Because the result is wrong? Correct result: x <- 4. Sorry for my bad English
댓글 수: 2
답변 (2개)
MHN
2016년 4월 28일
편집: MHN
2016년 4월 28일
It gives you the first integer number that meets the criteria (f<0) which is -5 (for -4 you should write f<=0). Matlab is not a good tool for symbolic calculation and I do not think it gives you that result (x<-4, or x<=-5). Btw, of course it is not a bug in solve function !!!
Raghad Alharbi
2022년 2월 16일
Selection = menu ('Welcome to Relations' ...
'Reflexivity' ...
'Symmetry' ...
'Transitivity' ...
'Exit the menu')
A = [0,1,2,3,4,5]; Z1 = []; Z2 = []; Z3 = [];
while Selection < 7
switch Selection
case 1 Reflexivity
i = 1;
while i < 7
n1 = input(' Enter rfist integer for n1; ');
if ismember ([n1],A) == 1
fprintf('n1 belongs to A\n')
break
else
i = i+1;
end
end
i = 1;
while i < 7
n2 = input('Enter rfist integer for n2; ');
if ismember ([n2],A) == 1
fprintf('n1 belongs to A\n')
break
else
i = i+1;
end
end
if ismember([n1],A) == 1 && ismember ([n2],A) == 1 && n1 == n2
fprintf('Yes, R Reflexivity\n')
else
fprintf('No, R is not Reflexivity\n')
end
case 2 Symmetry
n1 = input('Enter frist integer for n1: ');
n2 = input('Enter second integer for n2: ');
if ismember ([n1], A) == 1 && ismember ([n2] ,A) == 1 && n1 ~= n2
Z1 (end + 1) = n1;
Z1 (end + 1) = n2;
Z2 (end + 1) = n2;
Z2 (end + 1) = n1;
fprintf('Yes, R Symmetry\n')
else
fprintf('no, R is not Symmetry\n')
end
case 3 Transitivity
n1 = input('Enter frist integer for n1: ');
n2 = input('Enter second integer for n2: ');
n3 = input('Enter third integer for n3: ');
if ismember ([n1], A) == 1 && ismember ([n2] ,A) == 1 && ismember ([n3], A) == && n1 ~= n2 && n2 ~= n3
Z1 (end + 1) = n1;
Z1 (end + 1) = n2;
Z2 (end + 1) = n2;
Z2 (end + 1) = n3;
Z3 (end + 1) = n1;
Z3 (end + 1) = n3;
fprintf('Yes, R Transitivity\n')
else
fprintf('no, R is not Transitivity\n')
end
case 4 Exit menu
break;
end
Selection = menu('Welcome to Reflexivity, Symmetry, and Transitivity' ...
'Reflexivity' ...
'Symmetry' ...
'Transitivity' ...
'Exit the menu')
end
fprintf('You have left the menu, Have a good day!\n')
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!