Transpose of a symbolic 'real' results in conj()

조회 수: 9 (최근 30일)
Chris B
Chris B 2018년 7월 11일
답변: Yuichi Tadokoro 2018년 7월 13일
Hello,
I'm facing an issue where I define a symbol as real, assign an expression to it (trigonometric in this case) and transpose it. Unfortunately, the result includes conjugate elements.
Minimal example:
a = sym('a', 'real');
b = sym('b', 'real');
c = sym('c', [3,1], 'real');
c(1) = sin(a)*cos(b);
assume(c,'real')
result = c'
Result:
[ cos(conj(b))*sin(conj(a)), c2, c3]
The issue does not occur with assume(c, 'real') removed. The reason why it would make sense to have it is that overwriting c with a term might remove the assumption of the former definition.
If I run "assumptions", for the case without assume(c,'real') it shows:
[ in(a, 'real'), in(b, 'real'), in(c1, 'real'), in(c2, 'real'), in(c3, 'real')]
and with assume(c,'real'):
[ in(cos(b)*sin(a), 'real'), in(c1, 'real'), in(c2, 'real'), in(c3, 'real')]
The only difference is that it now assumes the whole term c(1) = cos(b)*sin(a) to be real.
Of course, I could use the element-wise transpose:
result = c.'
This works and does not result in conjugate elements. But the overall issue I'm facing is that I depend on all functions that are used on c, would need to do element-wise transpose. I, for instance, calculate the rank of a matrix based on elements similar to c and it seems that there is one more linear dependent row than compared to other mathematical tools.
Thanks in advance.

채택된 답변

Yuichi Tadokoro
Yuichi Tadokoro 2018년 7월 13일
You need to use
assumeAlso(c, 'real')
instead of 'assume' to keep the assumptions on a and b.
>> assumptions
ans =
[ in(cos(b)*sin(a), 'real'), in(a, 'real'), in(b, 'real'), in(c1, 'real'), in(c2, 'real'), in(c3, 'real')]

추가 답변 (0개)

카테고리

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