Borrar filtros
Borrar filtros

Evaluating matrices of class "sym".

5 visualizaciones (últimos 30 días)
ross montgomery
ross montgomery el 30 de Nov. de 2011
My algorithm returns matrices in the class "sym", of a similar form to the following matrix.
matrix =
[ a^2 + b*c, a*b + b*d]
[ a*c + c*d, d^2 + b*c]
For certain elements of this matrix I wish to allow the symbols involved in the element to assume a value (for the letters a, b, c, d) or the associated operation (for the operators '+', '*'). As such, if a=1, b=2 and c=3,
matrix(1,1)= 1*1 + 2*3
Which would then yield the answer, matrix(1,1) = 7.
Any help would be greatly appreciated.
Regards
Ross

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 30 de Nov. de 2011
syms a b c d
mtx = [ a^2 + b*c, a*b + b*d; a*c + c*d, d^2 + b*c]
subs(mtx,[a b c ],[1 2 3 ])
  1 comentario
ross montgomery
ross montgomery el 2 de Dic. de 2011
Thanks for your help Andrei,
Don't know how I didn't come across this in the help section.
Regards
Ross

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Formula Manipulation and Simplification en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by