Question

106/); [15] A particular sequence has the recursive formula In+3 = In+1 +sin(tn) where n = 0,1,2,3,... and we have that to =

Please use Matlab and good commenting.

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

Matlab code for the problem

clc; clear; % clearing the command window and workspace

t = zeros(1,10000); % initilizing the t vector with all zeros

t(1) = 3; % t_0 value

t(2) = 1; % t_1 value

for n = 1:1000-2 % loop to calculate first 10000 terms

t(n+2) = t(n+1) + sin(t(n)); % calculating 10000 terms of the sequence

end

plot(t,'ro'); % plotting the t values as red circles

title('t_{n+2} = t_{n+1}+sin(t_n)'); % adding the title to the plot

xlabel('n'), ylabel('y_n') % sdding the x and y axis labels

n = [0:9, 9800:9999]'; % n vectors

tn = t(n+1)'; % tn from first 10 and last 200

fid = fopen('tn_table.doc','w'); % opening the file to write table

fprintf(fid,'n\t\t tn\n'); % printing the title of the table in the doc

fprintf('n\t\t tn\n'); % printing the title of the table in the doc

for i = 1: length(n) % loop to print the table details

fprintf(fid,'%d\t\t %0.7f\n',n(i),tn(i)); % printing the data to file

fprintf('%d\t\t %0.7f\n',n(i),tn(i)); % printing the data to command window

end % end of loop

Screen Print of the code

2 3 4 5 6 7 8 clc; clear; % clearing the command window and workspace t = zeros(1,10000); % initilizing the t vector with all

Screen Print of the outputs

COMMAND WINDOW tn 0 1 2 3 4 5 6 7 8 9 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 9812 9813 9814 9815 9816 98

Figure 1 x + tn+2 = (n+1+sin(tn) 4.5 4 POVE 3.5 3 2.5 Yn 25 1.5 18 0.5 0 0 2000 4000 6000 8000 10000 n

tn_table.docx + 1 n tn 2 0 3.0000000 3 1 1.0000000 4 2 1.1411200 5 3 1.9825910 64 2.8916916 7 5 3.8080956 8 6 4.0554037 9 7 3

Add a comment
Know the answer?
Add Answer to:
Please use Matlab and good commenting. 106/); [15] A particular sequence has the recursive formula In+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