Question: please show all steps for both questions. MATLAB code, thank you. 2. Write a while loop that produces the same result as problem 1. You'll
2. Write a while loop that produces the same result as problem 1. You'll need to initialize an index, and then increment it within the loop. This is a script, not a function. 3. Write a function to calculate the sum of the reciprocals of a series of odd numbers. The function will have one input and no output, with the input being the ending value for the series of odd values. a) Write the function definition statement b) Initialize a variable to zero. This variable will contain the sum of all the values. c) Create a for loop that loops over all odd numbers from 1 to the specified ending value. d) Inside the loop, add the reciprocal of the current loop index to the running sum (variable defined in step b.) e) End the loop. f) Print the result to the screen using fprintf and specifying 6 decimal places. g) End the function. If you run it with an input of 51 you should get the result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
