Filter löschen
Filter löschen

Symbolic transpose of a matrix with the dimension not defined

1 Ansicht (letzte 30 Tage)
Álvaro
Álvaro am 7 Apr. 2016
Kommentiert: Walter Roberson am 8 Apr. 2016
Hello,
I am trying to work with symbolic variables in Matlab but I have a little problem. I want to work with general expressions without specify the dimensions of the matrix. For example if I define A as a symbolic variable and I use "transpose(A)" I want to receive "transpose(A)" and not this:
>> syms A
transpose(A)
ans =
A
>> A = sym('a',[3 3]);
transpose(A)
ans =
[ a1_1, a2_1, a3_1]
[ a1_2, a2_2, a3_2]
[ a1_3, a2_3, a3_3]
I have a huge expression that I want to simplify later with the command "simplify".
Thank you in advance, Álvaro

Antworten (1)

Walter Roberson
Walter Roberson am 7 Apr. 2016
Perhaps define a symbolic function Tr(M) without giving a definition for it, and apply it as needed. When it comes time to substitute actual matrix dimensions for A, you can also substitute a transpose function for Tr which would trigger the transposes.
  2 Kommentare
Álvaro
Álvaro am 8 Apr. 2016
great! it is working in the way that I want. Thank you for your answer.
I have now another issue. I have a really long symbolic expression that i want to contract using the function horner. Unfortunately it is not working for me and I dont now why. For example when I try do something like this it works
>> syms x y
>> f = x*x + x*y + x*x*x
f =
x^3 + x^2 + y*x
>> horner(f)
ans =
x*(y + x*(x + 1))
>>
but with my expression that it's really similar it doesn't contract the expression. Can you help me?
Thank you again
Walter Roberson
Walter Roberson am 8 Apr. 2016
horner cannot do much unless it finds something that looks like a monomial . It does not take much to throw off horner.
Often more useful than horner() is collect()
But I would need to see more of the structure of your expression to say more.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by