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

6 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 22 Apr. 2019
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 Kommentare
Walter Roberson
Walter Roberson am 25 Apr. 2019
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 am 26 Apr. 2019
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by