How do I solve a system of equations?

18 ビュー (過去 30 日間)
Mark Dillon
Mark Dillon 2015 年 8 月 11 日
回答済み: James Wiken 2015 年 8 月 13 日
I need to solve the following system of equations for x:
  • 10w-5x+3x-z = 1
  • 4x-4y = 2
  • z+7x+9w-5y = 3
  • 4w-1x+6y+4w+6w = 4
I tried using the solve command, but I don't think I am understanding how to use it properly
  2 件のコメント
John D'Errico
John D'Errico 2015 年 8 月 12 日
What did you try? Perhaps then we can help you better.
Mark Dillon
Mark Dillon 2015 年 8 月 12 日
if true
% code
solve(['10*w-2*x-z=1','4*x-4*y = 2','z+7*x+9*w-5*y = 3','14*w-x+6*y = 4'],[w,x,y,z]);
end

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

回答 (1 件)

James Wiken
James Wiken 2015 年 8 月 13 日
It looks like you are not quite using the correct syntax for the solve command. What you will want to do is first define 'w, x, y, z' as 'sym' variables.
syms w x y z
You can then define each equation using the 'sym' notation. For example, your first equation would change from
'10*w-2*x-z=1'
to
10*w-2*x-z == 1
You may want to look at the following documentation page for the 'solve' function:
An example of solving linear equations using the Symbolic Toolbox can also be found here:
You could also solve this system of equations numerically. Because the system of equations you are solving is linear, you can also rewrite the system of equations into matrix form. Refer to the following documentation link for doing this:
This method of solving the system of equations does not require using the Symbolic Toolbox and is generally much faster, especially if your system of equations is large and you do not need symbolic solutions.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by