Summation with Hyperbolic Tangent
古いコメントを表示
Hello, I am attempting to perform a summation that utilizes a hyperbolic tangent. A picture is attached of the desired equation. I have tried it with sum(), symsum(), and all sorts of other various ways, but have not had any luck. The most common error is either "Subscript indices must either be real positive integers or logicals." or a different error regarding indexing for symbolic variables. For the symbolic way, I made X the variable, and for normal summation I tried various constant values with no success.
回答 (1 件)
Walter Roberson
2016 年 7 月 11 日
syms x
tF = tanh(100 * (x-1/sym(4)));
F = sum( subs(tF, x, 1:4) );
The result will be tanh(75) + tanh(175) + tanh(275) + tanh(375)
It seems a little odd to sum over your only variable. I would have thought it more likely you would want something like
syms x n
tF = tanh(100 * (x-1/sym(4))^n);
F = sum( subs(tF, n, 1:4) );
which would give
tanh(100*(x - 1/4)^2) + tanh(100*(x - 1/4)^3) + tanh(100*(x - 1/4)^4) + tanh(100*x - 25)
カテゴリ
ヘルプ センター および File Exchange で Common Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!