필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Lillian
Lillian 2014년 5월 10일
댓글: Lillian 2014년 5월 10일
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

채택된 답변

Mischa Kim
Mischa Kim 2014년 5월 10일
편집: Mischa Kim 2014년 5월 10일
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
Lillian
Lillian 2014년 5월 10일
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!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by