How to skip the division of zero in three summation term.

조회 수: 6 (최근 30일)
Chee Hao Hor
Chee Hao Hor 2019년 4월 22일
댓글: Chee Hao Hor 2019년 4월 26일
F=n-M-N;
syms n M N
T= symsum(symsum(symsum((1/F),n,1,3),M,1,3),N,1,3);
Hi everybody,
I am trying to solve a problem, which involving three summation terms in the Temperature, denoted as T. Each of the sum range from 1 to 3.
However, there are certain value gives division by zero condition. How can I skip this condition while it add up others non-zero terms and give me a value ?
Desperately need the helps. Thanks.

채택된 답변

Walter Roberson
Walter Roberson 2019년 4월 22일
syms n M N
F = n-M-N;
Fz = piecewise(F == 0, 0, 1/F);
T = symsum( symsum( symsum( Fz, n, 1, 3), M, 1, 3), N, 1, 3)
  댓글 수: 23
Walter Roberson
Walter Roberson 2019년 4월 25일
In C13 you have a division by (pi.^2.*((Pr.*(M.^2+N.^2))-n.^2)) . Your pr is 1, so that becomes (pi.^2 * (M^2 + N^2 - n^2)) . Which gives a divison by 0 if the values satisfy a pythagorian triple, such as n = 5, N = 3, M = 4
Chee Hao Hor
Chee Hao Hor 2019년 4월 26일
I keep on looking at exp term yesterday. I had put this under the piecewise line, it works now !
I guess i have 1 last question. Suppose, solving this code, i can get 1 line in a graph of Y against T, at 1 value of b. To put 3 value of b in a single graph, i copy and paste the code 3 times. I try to change the b, from
b=10;
%to
b=[1,2,3];
It still give me a value only. Please advise.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by