Effacer les filtres
Effacer les filtres

Why is the word "and" coming up in my output?

1 vue (au cours des 30 derniers jours)
Lillian
Lillian le 10 Mai 2014
Commenté : Lillian le 10 Mai 2014
I am trying to simplify an expression, but the word "and" keeps popping up in my result. When I try to work with this further, I get, "unexpected matlab expression." My script is:
syms A B C D p q r s t u;
y00 = cos(A + B + C + D);
y0 = expand(y00);
y1 = subs(y0,cos(A),(cosh(p)*cosh(q)-cosh(t)) / (sinh(p)*sinh(q)));
y2 = subs(y1,cos(B),(cosh(q)*cosh(r)-cosh(u)) / (sinh(q)*sinh(r)));
y3 = subs(y2,cos(C),(cosh(r)*cosh(s)-cosh(t)) / (sinh(r)*sinh(s)));
y4 = subs(y3,cos(D),(cosh(s)*cosh(p)-cosh(u)) / (sinh(s)*sinh(p)));
y5 = subs(y4,sin(A),(1-cosh(p)^2-cosh(q)^2-cosh(t)^2+cosh(p)*cosh(q)&cosh(t)) / (sinh(p)*sinh(q)));
y6 = subs(y5,sin(B),(1-cosh(q)^2-cosh(r)^2-cosh(u)^2+cosh(q)*cosh(r)&cosh(u)) / (sinh(q)*sinh(r)));
y7 = subs(y6,sin(C),(1-cosh(r)^2-cosh(s)^2-cosh(t)^2+cosh(r)*cosh(s)&cosh(t)) / (s inh(r)*sinh(s)));
y8 = subs(y7,sin(D),(1-cosh(s)^2-cosh(p)^2-cosh(u)^2+cosh(s)*cosh(p)&cosh(u)) / (sinh(s)*sinh(p)));
y8
the answer that I keep getting is:
y8 =
(((cosh(u) and cosh(q)*cosh(r) - cosh(q)^2 - cosh(r)^2 - cosh(u)^2 + 1)*(cosh(t) and cosh(p)*cosh(q) - cosh(p)^2 - cosh(q)^2 - cosh(t)^2 + 1))*(cosh(u) and cosh(p)*cosh(s) - cosh(p)^2 - cosh(s)^2 - cosh(u)^2 + 1)*(cosh(t) and cosh(r)*cosh(s) - cosh(r)^2 - cosh(s)^2 - cosh(t)^2 + 1))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(t) and cosh(p)*cosh(q) - cosh(p)^2 - cosh(q)^2 - cosh(t)^2 + 1)*(cosh(u) and cosh(p)*cosh(s) - cosh(p)^2 - cosh(s)^2 - cosh(u)^2 + 1))*(cosh(u) - cosh(q)*cosh(r))*(cosh(t) - cosh(r)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(t) and cosh(p)*cosh(q) - cosh(p)^2 - cosh(q)^2 - cosh(t)^2 + 1)*(cosh(u) and cosh(q)*cosh(r) - cosh(q)^2 - cosh(r)^2 - cosh(u)^2 + 1))*(cosh(u) - cosh(p)*cosh(s))*(cosh(t) - cosh(r)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(t) and cosh(p)*cosh(q) - cosh(p)^2 - cosh(q)^2 - cosh(t)^2 + 1)*(cosh(t) and cosh(r)*cosh(s) - cosh(r)^2 - cosh(s)^2 - cosh(t)^2 + 1))*(cosh(u) - cosh(p)*cosh(s))*(cosh(u) - cosh(q)*cosh(r)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(u) and cosh(q)*cosh(r) - cosh(q)^2 - cosh(r)^2 - cosh(u)^2 + 1)*(cosh(u) and cosh(p)*cosh(s) - cosh(p)^2 - cosh(s)^2 - cosh(u)^2 + 1))*(cosh(t) - cosh(p)*cosh(q))*(cosh(t) - cosh(r)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(u) and cosh(q)*cosh(r) - cosh(q)^2 - cosh(r)^2 - cosh(u)^2 + 1)*(cosh(t) and cosh(r)*cosh(s) - cosh(r)^2 - cosh(s)^2 - cosh(t)^2 + 1))*(cosh(t) - cosh(p)*cosh(q))*(cosh(u) - cosh(p)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(t) and cosh(r)*cosh(s) - cosh(r)^2 - cosh(s)^2 - cosh(t)^2 + 1)*(cosh(u) and cosh(p)*cosh(s) - cosh(p)^2 - cosh(s)^2 - cosh(u)^2 + 1))*(cosh(t) - cosh(p)*cosh(q))*(cosh(u) - cosh(q)*cosh(r)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) + ((cosh(t) - cosh(p)*cosh(q))*(cosh(u) - cosh(p)*cosh(s))*(cosh(u) - cosh(q)*cosh(r))*(cosh(t) - cosh(r)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2)
when I try to do
factor(y8)
I get "unexpected matlab expression," pointing to the "and." Could anyone help me with this? Thanks

Réponse acceptée

Mischa Kim
Mischa Kim le 10 Mai 2014
Modifié(e) : Mischa Kim le 10 Mai 2014
Lucy, for example, in the expression for y5 there is a term
cosh(p)*cosh(q)&cosh(t)
(typo?) which results in an and. The same (copy-paste?) happens in the other expressions, y6 thru y8.
  1 commentaire
Lillian
Lillian le 10 Mai 2014
wow, yeah, I can't believe I didn't see that. I must have typed & instead of * and copied it into the other lines. thanks so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by