Solving Matrices with Symbolic Variables

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 comentarios

Shivam Prajapati
Shivam Prajapati el 2 de Jun. de 2020
null(A)
Walter Roberson
Walter Roberson el 2 de Jun. de 2020
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.

Iniciar sesión para comentar.

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 30 de Nov. de 2011
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 comentarios

Jared
Jared el 30 de Nov. de 2011
thanks alot works well, one minor adjustment:
k = cell2mat(A(:,1:3))\-cell2mat(A(:,end));
Karan Gill
Karan Gill el 1 de Dic. de 2016
It's much simpler. See Kaixiang Wang's answer below.
JITHA K R
JITHA K R el 4 de En. de 2018
Can you explain the working of this code pls?

Iniciar sesión para comentar.

Más respuestas (2)

Kaixiang Wang
Kaixiang Wang el 30 de Nov. de 2016
Editada: Kaixiang Wang el 30 de Nov. de 2016
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 comentarios

Shivam Prajapati
Shivam Prajapati el 2 de Jun. de 2020
Null(A) % null is matlab command
Walter Roberson
Walter Roberson el 2 de Jun. de 2020
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.

Iniciar sesión para comentar.

Walter Roberson
Walter Roberson el 30 de Nov. de 2011
Editada: John Kelly el 27 de Mayo de 2014

0 votos

Linear algebra with symbolic matrices is discussed at http://www.mathworks.com/products/symbolic/

3 comentarios

Charles
Charles el 13 de Nov. de 2023
how to downvote this answer?
Walter Roberson
Walter Roberson el 13 de Nov. de 2023
In particular these days, that page leads to https://www.mathworks.com/help/symbolic/linear-algebra.html
Dyuman Joshi
Dyuman Joshi el 13 de Nov. de 2023
@Charles, Why exactly do you want to that?

Iniciar sesión para comentar.

Preguntada:

el 30 de Nov. de 2011

Comentada:

el 13 de Nov. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by