필터 지우기
필터 지우기

Matrix differentiation

조회 수: 87 (최근 30일)
rami
rami 2012년 6월 6일
Hi
I have matrix (3,3)in the form
M=[cos(a)*sin(b)*cos(c) sin(a)*sin(b)*sin(c) cos(a)^2*sin(b)^2*cos(c);.............;.......]
where a , b , c angls changing with the time
How i can differentiation the M according to time Mdott
Thx

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 6월 6일
syms a b c t
M=[cos(a)*sin(b)*cos(c) sin(a)*sin(b)*sin(c) cos(a)^2*sin(b)^2*cos(c)];
k = regexprep(char(M),{'\(a\)','\(b\)','\(c\)'},{'\(a\(t\)\)', '\(b\(t\)\)', '\(c\(t\)\)'});
out = feval(symengine,'diff', k, t)
ADD after rami's comment
z = feval(symengine,'diff', k, t);
out = sym(regexprep(char(z),'(\(t\))|(\*diff\([abc]\(t\), t\))',''))
  댓글 수: 1
rami
rami 2012년 6월 6일
Ok
As example
M=[cos(a)*sin(b)*cos(c) sin(a)*sin(b)*sin(c) cos(a)^2*sin(b)^2*cos(c);1 1 1;1 1 1];
k = regexprep(char(M),{'\(a\)','\(b\)','\(c\)'},{'\(a\(t\)\)', '\(b\(t\)\)', '\(c\(t\)\)'});
out = feval(symengine,'diff', k, t)
I have the result:
out =
[ cos(a(t))*cos(b(t))*cos(c(t))*diff(b(t), t) - cos(c(t))*sin(a(t))*sin(b(t))*diff(a(t), t) - cos(a(t))*sin(b(t))*sin(c(t))*diff(c(t), t), cos(a(t))*sin(b(t))*sin(c(t))*diff(a(t), t) + cos(b(t))*sin(a(t))*sin(c(t))*diff(b(t), t) + cos(c(t))*sin(a(t))*sin(b(t))*diff(c(t), t), 2*cos(b(t))*cos(c(t))*diff(b(t), t)*cos(a(t))^2*sin(b(t)) - sin(c(t))*diff(c(t), t)*cos(a(t))^2*sin(b(t))^2 - 2*cos(c(t))*sin(a(t))*diff(a(t), t)*cos(a(t))*sin(b(t))^2]
[ 0, 0, 0]
[ 0, 0, 0]
Is there any way to disappear the term diff(b(t), t),...

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 6월 6일
I am relatively sure the below should work:
syms a b c t
M=[cos(a(t))*sin(b(t))*cos(c(t)) sin(a(t))*sin(b(t))*sin(c(t)) cos(a(t))^2*sin(b(t))^2*cos(c(t));.............;.......]
diff(M, t)
What might also work, at least with sufficiently new Symbolic Toolbox, is
syms a(t) b(t) c(t) t
M=[cos(a)*sin(b)*cos(c) sin(a)*sin(b)*sin(c) cos(a)^2*sin(b)^2*cos(c);.............;.......]
diff(M,t)
  댓글 수: 2
rami
rami 2012년 6월 6일
syms a b c t
A=[cos(a(t))*sin(b(t))*sin(c(t)) sin(a(t))*cos(c(t)) 1;0 0 0;1 1 1]
diff(A, t)
Error in ==> POLEPLACEMENT at 9
A=[cos(a(t))*sin(b(t))*sin(c(t)) sin(a(t))*cos(c(t)) 1;0 0 0;1 1 1]
OR
syms a(t) b(t) c(t) t
M=[cos(a)*sin(b(t))*cos(c) sin(a(t))*sin(b(t))*sin(c(t)) cos(a(t))^2*sin(b(t))^2*cos(c(t));1 1 1;1 1 1];
diff(M, t)
Error in ==> POLEPLACEMENT at 12
syms a(t) b(t) c(t) t
rami
rami 2012년 6월 6일
syms a(t) b(t) c(t) t
M=[cos(a)*sin(b)*cos(c) sin(a)*sin(b)*sin(c) cos(a)^2*sin(b)^2*cos(c);1 1 1;1 1 1];
diff(M, t)
??? Error using ==> syms at 61
Not a valid variable name.
Error in ==> POLEPLACEMENT at 12
syms a(t) b(t) c(t) t

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by