Once the logical expression a t the start of a while loop is
Once the logical expression a t the start of a while loop is false, the statements after the end statement are executed. A. True B. False Answer: Write a MATLAB program to sum the following series with 500 terms by using for loops. 1/1^2 middot 3^2 + 1/3^2 middot 5^2 + 1/5^2 middot 7^2 ...
Solution
% matlab code
number = 1;
sum = 0;
% for loop to update sum
for term=1:500
% update sum
sum = sum + 1/(number^2 * (number+2)^2);
% increment denominator
number = number + 2;
end
% display result
fprintf(\"Sum of first 500 terms: %0.15f\ \",sum);
%output: Sum of first 500 terms: 0.116850274901917
