MATLAB Answers

Igor
1

Simbolic Toolbox: how to avoid conj() in matrix *

Asked by Igor
on 28 Dec 2011
Latest activity Answered by moh ab
on 26 Jun 2019
N=10;x=0:(N-1);
syms real r;
a=r.^(x),
b=r.^(-x),
M=b'*a
Result is
a =
[ 1, r, r^2, r^3, r^4, r^5, r^6, r^7, r^8, r^9]
b =
[ 1, 1/r, 1/r^2, 1/r^3, 1/r^4, 1/r^5, 1/r^6, 1/r^7, 1/r^8, 1/r^9]
M =
[ 1, r, r^2, r^3, r^4, r^5, r^6, r^7, r^8, r^9]
[ 1/conj(r), r/conj(r), r^2/conj(r), r^3/conj(r), r^4/conj(r), r^5/conj(r), r^6/conj(r), r^7/conj(r), r^8/conj(r), r^9/conj(r)]
[ 1/conj(r)^2, r/conj(r)^2, r^2/conj(r)^2, r^3/conj(r)^2, r^4/conj(r)^2, r^5/conj(r)^2, r^6/conj(r)^2, r^7/conj(r)^2, r^8/conj(r)^2, r^9/conj(r)^2]
[ 1/conj(r)^3, r/conj(r)^3, r^2/conj(r)^3, r^3/conj(r)^3, r^4/conj(r)^3, r^5/conj(r)^3, r^6/conj(r)^3, r^7/conj(r)^3, r^8/conj(r)^3, r^9/conj(r)^3]
[ 1/conj(r)^4, r/conj(r)^4, r^2/conj(r)^4, r^3/conj(r)^4, r^4/conj(r)^4, r^5/conj(r)^4, r^6/conj(r)^4, r^7/conj(r)^4, r^8/conj(r)^4, r^9/conj(r)^4]
[ 1/conj(r)^5, r/conj(r)^5, r^2/conj(r)^5, r^3/conj(r)^5, r^4/conj(r)^5, r^5/conj(r)^5, r^6/conj(r)^5, r^7/conj(r)^5, r^8/conj(r)^5, r^9/conj(r)^5]
[ 1/conj(r)^6, r/conj(r)^6, r^2/conj(r)^6, r^3/conj(r)^6, r^4/conj(r)^6, r^5/conj(r)^6, r^6/conj(r)^6, r^7/conj(r)^6, r^8/conj(r)^6, r^9/conj(r)^6]
[ 1/conj(r)^7, r/conj(r)^7, r^2/conj(r)^7, r^3/conj(r)^7, r^4/conj(r)^7, r^5/conj(r)^7, r^6/conj(r)^7, r^7/conj(r)^7, r^8/conj(r)^7, r^9/conj(r)^7]
[ 1/conj(r)^8, r/conj(r)^8, r^2/conj(r)^8, r^3/conj(r)^8, r^4/conj(r)^8, r^5/conj(r)^8, r^6/conj(r)^8, r^7/conj(r)^8, r^8/conj(r)^8, r^9/conj(r)^8]
[ 1/conj(r)^9, r/conj(r)^9, r^2/conj(r)^9, r^3/conj(r)^9, r^4/conj(r)^9, r^5/conj(r)^9, r^6/conj(r)^9, r^7/conj(r)^9, r^8/conj(r)^9, r^9/conj(r)^9]

  0 Comments

Sign in to comment.

2 Answers

Answer by Andrei Bobrov
on 28 Dec 2011
 Accepted Answer

try use
syms r real
...
M=b.'*a

  8 Comments

Many thanks for your help. For below case, how can I define the every variable as real in the variable vecor 'a' ?
a = sym('a',[1,12])';
Found it! a = sym('a',[1,12],'real')';

Sign in to comment.


Answer by moh ab
on 26 Jun 2019

hi my friends
i have problem in result of equetion .
in my code
syms te1 te2 ted1 ted2
q=[cos(te1+te2) -sin(te1+te2) 0;...
sin(te1+te2) cos(te1+te2) 0;...
0 0 1]
q1 =
[ -sin(te1 + te2), -cos(te1 + te2), 0]
[ cos(te1 + te2), -sin(te1 + te2), 0]
[ 0, 0, 0]
q2 =
[ -ted2*sin(te1 + te2), -ted2*cos(te1 + te2), 0]
[ ted2*cos(te1 + te2), -ted2*sin(te1 + te2), 0]
[ 0, 0, 0]
t=q1+q2
z=t*.q'
the z(1,1)=0
but in result of matlab show
sin(te1 + te2)*(ted1*cos(te1 + te2) + ted2*cos(te1 + te2)) - cos(te1 + te2)*(ted1*sin(te1 + te2) + ted2*sin(te1 + te2))
how can i fix it ?

  0 Comments

Sign in to comment.