MATLAB simplify complex expressions

25 visualizzazioni (ultimi 30 giorni)
Dk
Dk il 9 Gen 2014
Modificato: Dk il 9 Gen 2014
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!

Risposte (2)

Mischa Kim
Mischa Kim il 9 Gen 2014
Use the Symbolic Math Toolbox, see simplify command, for example.
  1 Commento
Dk
Dk il 9 Gen 2014
yes, but how to explain to simplify that nx^2+ny^2+nz^2 = 1; or ax*nx+ay*ny+az*nz = 0; ?

Accedi per commentare.


Roger Stafford
Roger Stafford il 9 Gen 2014
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 Commento
Dk
Dk il 9 Gen 2014
Modificato: Dk il 9 Gen 2014
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
??

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by