Question

1) Write a short script with a for-loop which will output the first 10 numbers in the Fibonacci sequence. (O, 1, 1, 2, 3, 5, 8,.. ao = 0,a, = 1, a2-1, a,-2, , an = an-2 + an-1 By using MatLab please.
Best.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please give the thumbs up, if it is helpful for you!!. Let me know if you have any doubts.

f(1) = 0;
f(2) = 1;
disp(f(1));
disp(f(2));
for i = 3 : 10
f(i) = f(i-1) + f(i-2);
str = [num2str(f(i))];
disp(str)
end

Execute le®Embed demo.m Stdin f(1) = 0; 2 f(2) 1; 3 disp(f(1)); 4 disp(f(2)); 5 for i= 3:10 str [num2str(f(i))]; 8 disp(str)

Output:

I.lI Result soctave -qf --no-window-system demo.m 21 warning: function /demo.m shadows a core library function

Add a comment
Know the answer?
Add Answer to:
By using MatLab please. Best. Write a short script with a 'for-loop' which will output the...
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