Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 4 Points: ( 78) Write a recursive function fibonacci in MATLAB that calculates the nth Fibonacci number where the user can specify the two
Question 4 Points: ( 78) Write a recursive function fibonacci in MATLAB that calculates the nth Fibonacci number where the user can specify the two starting numbers eg.: Starting Number 1: 4 Starting Number 2:6 N: 5 1st 2nd 3rd 4th 5th 4 6 (4+6) =10 (6+10) =16 (10+16) = 26 Your function should behave as follows: >> fibonacci (4, 6, 5) ans = 26 Question 5: Points: 16) Plot the surface of ** xy Z= 23 where x ranges from 0 to 10 in steps of 0.5, and y ranges from 3 to 5 in steps of 0.1. Points: 18) Question 6 The following code is given: function (A] - mystery function(n) Azeros(n); 1=1; 3:1; k=1; lon; for i=1:n for $110 14 ) for kj1 A(1,k) ui; Ak, 1)-1; end end end 1-1-1; eng end a) What would be the output of the following statement? >> Mystery_Matrix = mystery_function (4) b) Write the MATLAB statements to: save the element of the 3rd row and 4th column in Mystery_Matrix in the variable Mystery_Element. What value is now stored in Mystery Element? save Mystery Element in an ASCII file called mystery_file.txt. Question 7: Points: 110) The following script is supposed to continually ask the user for a numerical input until the number 'O' is entered. Afterwards, the script displays the sum of all the numbers, the max and min numbers, the product of all the numbers, and the mean of all the numbers. Mark and correct all the mistakes you find (syntax and logical errors which would crash the program or result in wrong output) clear all; close all; clc; number=1; starting condition sum=0; variable to calculate the sum of all mitbers prod=0; varlable to calculate the product flag=1; flag to determine the first run of the while loop counter=0; 1 counter to count the entered numbers for number-=0 number=input('Please enter a number: ',''); sum=sum+number; if flag=1 run only if it is the first time max_number=number; set max to number min_number=number; set min to number flag=0; reset Elag to zero end if number==0 only execute if a non zero number was entered prod=prod*number; * calculate product if number
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started