I've been trying to estimate this expression with while loop

回答(1 个)

There is no need to use a slow while loop when you can use much faster vectorized code:
N = 1:100;
X = sqrt(12*sum((-1).^(N+1)./N.^2))

类别

在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by