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
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
