Solving Matrices with Symbolic Variables

236 次查看(过去 30 天)
I am trying to figure out how to solve a problem such as [A]{X}={0} where [A] is a numerical matrix such as
[1 2 3 4]
[5 6 7 8]
[9 0 1 2]
and {X} is a symbolic matrix with a single numeric value such as
[1x1 sym; 1x1 sym; 1x1 sym; 1]
that is:
[a]
[b]
[c]
[1]
Is there a way to find a,b,c such that [A]{X}={0}
  2 个评论
Walter Roberson
Walter Roberson 2020-6-2
null() by itself does not work for the case where one or more of the X vectors are known constants, as is required by the Question.

请先登录,再进行评论。

采纳的回答

Andrei Bobrov
Andrei Bobrov 2011-11-30
A =[ 1 2 3 4
5 6 7 8
9 0 1 2]
syms a b c
x = [a;b;c]
k = A(:,1:3)\-A(:,end);
for i1 = 1 : numel(x)
eval([char(x(i1)),'=k(i1)']);
end
  3 个评论
Karan Gill
Karan Gill 2016-12-1
It's much simpler. See Kaixiang Wang's answer below.
JITHA K R
JITHA K R 2018-1-4
Can you explain the working of this code pls?

请先登录,再进行评论。

更多回答(2 个)

Kaixiang Wang
Kaixiang Wang 2016-11-30
编辑:Kaixiang Wang 2016-11-30
Simply use MATLAB symbolic toolbox and the solve() function.
syms a b c
A=[1 2 3 4;5 6 7 8;9 0 1 2]
X=[a;b;c;1]
sol=solve(A*X)
  2 个评论
Walter Roberson
Walter Roberson 2020-6-2
null() by itself does not work for the case where one or more of the X vectors are known constants, as is required by the Question.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2011-11-30
编辑:John Kelly 2014-5-27
Linear algebra with symbolic matrices is discussed at http://www.mathworks.com/products/symbolic/

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by