Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MFDBS 91 3rd Symposium On Mathematical Fundamentals Of Database And Knowledge Base Systems Rostock Germany May 6 9 1991

Authors: Bernhard Thalheim ,Janos Demetrovics ,Hans-Detlef Gerhardt

1991st Edition

3540540091, 978-3540540090

More Books

Students also viewed these Databases questions

Question

Define marketing concepts.

Answered: 1 week ago

Question

1 what does yellow colour on the map represent?

Answered: 1 week ago