MATLAB simplify complex expressions

조회 수: 25 (최근 30일)
Dk
Dk 2014년 1월 9일
편집: Dk 2014년 1월 9일
Dear MATLAB experts, I have one problem: i have huge expressions with the members like
... - 2*L1*nz*nx^2 - 2*L1*nz*ny^2 - 2*L1*nz*nz^2 ...
or
... - Cb*L3*Sb^2*ax*nx- Cb*L3*Sb^2*ay*ny- Cb*L3*Sb^2*az*nz ...
and I know that nx^2+ny^2+nz^2 = 1; or ax*nx+ay*ny+az*nz = 0;
but how I can explain this to MATLAB in order to simplify expressions Thanks for any help!

답변 (2개)

Mischa Kim
Mischa Kim 2014년 1월 9일
Use the Symbolic Math Toolbox, see simplify command, for example.
  댓글 수: 1
Dk
Dk 2014년 1월 9일
yes, but how to explain to simplify that nx^2+ny^2+nz^2 = 1; or ax*nx+ay*ny+az*nz = 0; ?

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


Roger Stafford
Roger Stafford 2014년 1월 9일
You can try the following. The two identities which you require,
nx^2+ny^2+nz^2 = 1 and ax*nx+ay*ny+az*nz = 0
reduce the number of degrees of freedom in nx, ny, nz, ax, ay, and az from six to four. Therefore make the following parametric substitutions for them in terms of the four parameters p, q, r, and t:
nx = cos(p)*sin(q)
ny = sin(p)*sin(q)
nz = cos(q)
ax = t*(sin(p)*cos(r)+cos(p)*cos(q)*sin(r))
ay = t*(-cos(p)*cos(r)+sin(p)*cos(q)*sin(r))
az = -t*sin(q)*sin(r)
It is easy to check that these must satisfy your two equations identically. Then attempt to simplify these expressions in terms of the four variables, p, q, r, and t.
Your final simplified form may still contain some or all of these four parameters. I think it is quite possible in the problem you pose that a simplified form of your original expressions will probably have to be in a parametric form such as this in view of your identity requirements.
  댓글 수: 1
Dk
Dk 2014년 1월 9일
편집: Dk 2014년 1월 9일
Thank you for your answer! Yes, the problem will be that my simplified expressions will contain that four parameters... maybe it/s possible to "collect" them with respect to nx^2+ny^2+nz^2
or ax*nx+ay*ny+az*nz
??

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

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by