for limit=logspace(2,4,3)
sum=0;
for n= 1:limit
sum=sum+1/n^2;
end
error=abs((pi^2/6)-sum);
disp([limit,sum,error]);
end
Cite As
Arthur Matlabus (2026). for and logspace (https://www.mathworks.com/matlabcentral/fileexchange/167406-for-and-logspace), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2024a
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
