sum = 0;n = 0;C = (2/(pi*(1-4*n^2)))^2;while sum < (1/2)*0.99 n = n+1; sum = sum + C;enddisp(['number of terms:',num2str(n),'sum',num2str(sum)])
These are my codes. I want matlab to keep calculating until sum is greater than 99% of a half. However it stops at the first calculation and the result is clearly wrong. Any help would be greatly appreciated! Thanks!
Best Answer