フィルターのクリア

Possible solutions of an equation

1 回表示 (過去 30 日間)
Mondeep maz
Mondeep maz 2018 年 8 月 14 日
コメント済み: Mondeep maz 2018 年 9 月 18 日
Need to solve an equation and find all the possible solutions. For eg: X(1)+X(2)+X(3) = 4 where 0<X(1),X(2),X(3)<2

採用された回答

Kevin Chng
Kevin Chng 2018 年 9 月 18 日
編集済み: Kevin Chng 2018 年 9 月 18 日
Replace X(1) with X
Replace X(2) with Y
Replace X(3) with Z
no possible solution if 0<X,Y,Z<2 . It is because there is only 1 possible number for X,Y,Z which is 1. 1+1+1 =3 ~=4
let say your range is 0<=X,Y,Z<=2
for X=0:1:2
for Y = 0:1:2
for Z = 0:1:2
if (X+Y+Z) == 4
sprintf('%d + %d + %d =4, X is %d, Y is %d, Z is %d',X,Y,Z,X,Y,Z)
end
end
end
end
Hope code above help you
  1 件のコメント
Mondeep maz
Mondeep maz 2018 年 9 月 18 日
Thank you kevin...

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by