Summation with Hyperbolic Tangent
Mostrar comentarios más antiguos
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.
Respuestas (1)
Walter Roberson
el 11 de Jul. de 2016
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)
Categorías
Más información sobre Common Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!