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