Question: In matlab 1. Write a for loop ranging from 3 to 5. In the loop, print the value of the loop index to the screen

In matlab 1. Write a for loop ranging from 3 to 5. In the loop, print the value of the loop index to the screen using fprintf in the following format: Value is n where n is not the letter "n," but is the value of the associated loop index. This is a script, not a function. 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: total = 2.610834
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
