フィルターのクリア

Why does matlab give me the wrong answer?

2 ビュー (過去 30 日間)
Linus Heierhoff
Linus Heierhoff 2019 年 9 月 14 日
コメント済み: Rik 2019 年 9 月 20 日
why?
  2 件のコメント
Rik
Rik 2019 年 9 月 14 日
3-2 is 1, which is greater than 0. How is this result wrong?
Linus Heierhoff
Linus Heierhoff 2019 年 9 月 14 日
I would think that i would get something like this as a answer.
ans > 2

サインインしてコメントする。

回答 (1 件)

Priyanshu Mishra
Priyanshu Mishra 2019 年 9 月 18 日
Although this answer is not wrong, but for getting conditions on the solution, set ‘ReturnConditions’ to true. It will return any parameter in the solution and conditions on the solution. You can try following code:
clear all; close all; clc;
syms x;
eqn = x-2 >= 0;
assume (eqn)
S= solve (eqn,x,'ReturnConditions',true)
S.conditions
  5 件のコメント
Priyanshu Mishra
Priyanshu Mishra 2019 年 9 月 20 日
Hi Rik, I kind of agree with you. It completely depends upon the user whether he wants to close all the windows or not. I have written this code from the scratch and I just used those commands for my convenience. The user can start from line 2 .
Rik
Rik 2019 年 9 月 20 日
My problem is that many inexperienced users always see those together and don't understand what they do, but assume they are all required to set up a working script. I have no problem with people using them (I use them myself regularly), but I do think we should be selective in what we put in our answers, because like it or not, we are teaching people best practices every time we post an answer.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by