Using a forloop write the MATLAB code to calculate the sum o
Using a for-loop. write the MATLAB code to calculate the sum of the following series: sum = 1/1 + Squareroot 2 + 1/Squareroot 3 + Squareroot 4 + ... + 1/Squareroot 623 + Squareroot 624 + 1/Squareroot 624 + Squareroot 625
Solution
%summation of given series using for loop
clc
clear all
x(1) = zeros(624,1); % preallocate space for each term
for i = 1: 624
x1(i) = (1 /(sqrt(i) + sqrt(i+1))) % store each term
end
xs = sum(x1) % sum each stored term
