Solving Linear System of Equations with a Real Parameter

41 ビュー (過去 30 日間)
Gauss
Gauss 2019 年 11 月 30 日
回答済み: Steven Lord 2019 年 12 月 2 日
Hi, I'm a University Student, I never used Matlab and I have to solve with Matlab several Linear Systems of Equations with a Real Parameter, like this:CodeCogsEqn (1).png
λ∈ℝ
Since I really don't know anything about Matlab it would be great if there is some sort of Pre-Compiled code to solve this kind of Systems so every time I just have to replace the values in the equations and I can easily get the solutions I need.
Thanks a lot,
Have a nice one
  4 件のコメント
Gauss
Gauss 2019 年 11 月 30 日
You are not the problem, disrespectful people are.
Every time I ask on a forum looking for help I get insulted.
Not the right way to behave, for sure.
If you know the answer to mi question though I'd appreciate it.
Thanks
Star Strider
Star Strider 2019 年 11 月 30 日
編集済み: Star Strider 2019 年 11 月 30 日
@Gauss —
My pleasure.
Jim Riggs posted one that may be helpful.

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

採用された回答

Jim Riggs
Jim Riggs 2019 年 11 月 30 日
編集済み: Jim Riggs 2019 年 11 月 30 日
Using the symbolic toolbox, you can solve it as follows:
1) Define symbolic quantities;
syms A B x1 x2 x3 x4 lamda
2) Write the problem in matrix form
A = [1 0 1 0; lamda 1 0 1; 1 1 1 1; 2 1 lamda 0; 0 0 1 1]; % 5 x 4 coefficient matrix
B = [x1; x2; x3; x4] % 4 x 1 column matrix
3) solve the system of equations
[v1, v2, v3, v4, v5] = solve(A*B==[1; lamda; 1; lamda; 1]);
The result:
v1 = value of x1
v2 = value of x2
v3 = value of x3
v4 = value of x4 and
v5 = value of lamda
I get two sets of solutions:
v1 v2 v3 v4 v5 = 0 0 1 0 0 and
v1 v2 v3 v4 v5 = 1 1 -1 0 1

その他の回答 (1 件)

Steven Lord
Steven Lord 2019 年 12 月 2 日
What do you know and what are you trying to find?
Do you know the value of λand you're trying to find the X values? If so, build your coefficient matrix and right-hand side vector and use the backslash operator (\) to solve the system. Both the coefficient matrix and right-hand side will include λ. See the documentation page for the mldivide function for more information.
Do you know the values of X and you're trying to find λ? If so, you could use fzero on one of the equations that involve λ.
Do you know neither λ nor the values of X and you're trying to find all five? In this case you don't have a linear system, you have a nonlinear system (due to the λ*X1 and λ*X3 terms) and so you'd need to use something like fsolve from Optimization Toolbox.

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by