write a funn ion called aeries to do E 1 2\" functi go trom and The ingut argume
ID: 3822220 • Letter: W
Question
Explanation / Answer
% QUESTION-1
function [n vect] = series(req_value)
n = 0;
vect = []
current_val = 0;
while (current_val < req_value)
current_val = current_val + (1/2^n);
vect = [vect current_val];
n = n + 1;
end
end
[n vector] = series(1.99);
fprintf(" Value of n is %d Vector is ", n);
disp(vector);
% QUESTION-2
SUMS = [1.9 1.99 1.999 1.9999];
for i=1:length(SUMS)
fprintf("Values for %f ", SUMS(i));
[n vector] = series(SUMS(i));
fprintf(" Value of n is %d Vector is ", n);
disp(vector);
end
%QUESTION-3 is not visible properly
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.