Question

11. (10 points) - MATLAB ce of the alternating harmonic series, shown below: 1-2?--+ - 3 4 5 Use a loop to determine when the series has converged within a tolerance of 0.001. The animation should show how the value of the series changes as each successive term is added, resulting in a final

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Matlab Code:

clc;
clear;
sum=0;    %sum of series
i=1;      %iteration variable
er=1;    %error

% making animation and seting axes
curve=animatedline;
set(gca,'XLim',[0 1000],'Color',[.7 0.9 0.9]);
title('harmonic Series Animation','FontSize', 20);
xlabel('count','FontSize', 16); ylabel('Sum of Series','FontSize', 16);
while er>0.001
    nsum=sum+(-1)^(i+1)*1/i;
    S(i)=nsum;
    C(i)=i;
    addpoints(curve,C(i),S(i));
    drawnow
    i=i+1;
    er=abs(nsum-sum);
    sum=nsum;
end

Sample Output:

Run the above code ,

Below figure will be obtained at end of animation ..

harmonic Series Animation 0.95 0.9 0.85 0.8 0.75 CO 0.7 0,65 0.6 0.55 0.5 100 200 300 500 600 700 800 900 1000 count

Zoomed image:

harmonic Series Animation 0.85 0.8 0.75 O 0.7 0.65 0.6 10 20 40 50 60 count

Please comment if any doubt is there.. i will help. (y)

Add a comment
Know the answer?
Add Answer to:
11. (10 points) - MATLAB ce of the alternating harmonic series, shown below: 1-2?--+ - 3...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT