how to create a matrix with variables in it?

402 visualizaciones (últimos 30 días)
siva senthil
siva senthil el 12 de Feb. de 2013
Comentada: Walter Roberson el 25 de Abr. de 2021
for eg., to create following matrix and work on it,
A=[x1 x1*x2 ; x1^2 x2^2]

Respuestas (2)

Kye Taylor
Kye Taylor el 12 de Feb. de 2013
Editada: Kye Taylor el 12 de Feb. de 2013
The best answer to your question will likely depend on what you want to do with A. Sometimes, I find the following commands useful, which will create an anonymous function, A, that takes two inputs, x1 and x2 and returns the matrix you describe. Of course, this assumes you have values for the variables x1 and x2.
A = @(x1,x2)[x1,x1*x2;x1^2,x2^2]
And compute, for example, with
det(A(1,2))
If you want A to be symbolic, you can begin using the following command
syms x1 x2
A = [x1,x1*x2;x1^2,x2^2]
Then compute, for example, with
det(A)

Aman Kumar
Aman Kumar el 23 de Mzo. de 2021
syms x1 x2
A = [x1,x1*x2;x1^2,x2^2]
  2 comentarios
Michael Wolfe
Michael Wolfe el 25 de Abr. de 2021
How would you make a matrix with both numbers and variables in it?
Walter Roberson
Walter Roberson el 25 de Abr. de 2021
syms x1 x2
A = [x1,x1*pi;.8,x2^2]

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by