This is a MatLAB question Well give thumbs up for correct an

This is a MatLAB question. Well give thumbs up for correct answers.

The code says:
clear;
Series = 1;
N=9;
for k = 1:2:N-1
Series = Series + 1/(2^k);
end
Problem 3: Do not run the following Matlab script, instead you need to read the code and be able to predict the output. Show your work by creating a table which displays the values for k and Series while the loop is being executed (no work no credit). Paste predicted output here: How many times was the for loop executed with this code?

Solution

Loop will run till k=8. So it will run for 4 times.

k=1,series =1 + 1/(2^1) = 3/2.

k=3, series = 3/2 + 1/(2^3) = 1.625

k=5, series = 1.625 + 1/(2^5) = 1.65625

k=7, series = 1.65625 + 1(2^7) = 1.6640625

output:The value of series is: 1.66406 \

This is a MatLAB question. Well give thumbs up for correct answers. The code says: clear; Series = 1; N=9; for k = 1:2:N-1 Series = Series + 1/(2^k); end Proble

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site