Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a script in Matlab that will compute the first 20 numbers of the Fibonacc

ID: 3875549 • Letter: C

Question

Create a script in Matlab that will compute the first 20 numbers of the Fibonacci sequence. Use semi-colons after each command to keep the intermediate output from showing in the command window when you run the script. a. At the top of your script, write the following comments i. Your name ii. This short script will compute the first 20 Fibonacci numbers. Saving each number as a different variable with a unique name. b. The last variable should be called fib20. i. Ex: fib1 = first Fibonacci number, fib2 = second Fibonacci number, etc... c. Compute each Fibonacci number using variables of the previous numbers in the sequence (you cannot do this for the first two, as they are always 0 and 1 or 1 and 1. i. Ex: fib1 = 0: fib2 = 1: fib3 = fib1 + fib2: fib4 = fib2 + fib3: d. When you have finished, save your script as hw1_q3_script.m and run it. e. After you are satisfied that it is correct, type in the command to display the 20^th Fibonacci number that you computed (the last variable), to display the value in the command window. At this point you should save your workspace. Call the saved file hw1_ws.mat.

Explanation / Answer

Please prepend your name within comment before submitting the code!!

c
%% FILE NAMEL: hw1_q3_script.m

fib1 = 0;
fib2 = 1;
fib3 = fib1 + fib2;
fib4 = fib2 + fib3;
fib5 = fib3 + fib4;
fib6 = fib4 + fib5;
fib7 = fib5 + fib6;
fib8 = fib6 + fib7;
fib9 = fib7 + fib8;
fib10 = fib8 + fib9;
fib11 = fib9 + fib10;
fib12 = fib10 + fib11;
fib13 = fib11 + fib12;
fib14 = fib12 + fib13;
fib15 = fib13 + fib14;
fib16 = fib14 + fib15;
fib17 = fib15 + fib16;
fib18 = fib16 + fib17;
fib19 = fib17 + fib18;
fib20 = fib18 + fib19;

d)
Type the script name on the command line and press Enter. For example, to run the FILE NAMEL: hw1_q3_script.m script, type FILE NAMEL: hw1_q3_script.

e

To view 20th fibo nmber we type
fib20
and press enter

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote