How to set Reallyl Basic iterative sum

1 visualización (últimos 30 días)
Niklas Kurz
Niklas Kurz el 15 de En. de 2021
Editada: KSSV el 15 de En. de 2021
I want to sum up all n*sin(n*x)-terms. I've found that
f = n*sin(n*x)
for n = 1:10
f(n+1) = n*sin(n*x);
end
sum(f)
works. However, in my view it's not that elegant. In other words, how to implement without using 'sum'?

Respuesta aceptada

KSSV
KSSV el 15 de En. de 2021
Editada: KSSV el 15 de En. de 2021
% f = n*sin(n*x) ;
thesum = 0 ;
for n = 1:10
thesum = thesum+n*sin(n*x);
end

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by