Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(MATLAB) This problem is motivated by a previous assignment in which we plotted stock prices. Assume that the price for a given period of time

(MATLAB) This problem is motivated by a previous assignment in which we plotted stock prices. Assume that the price for a given period of time fluctuates between low and high. We want to display a y-axis with grid lines so that the entire range of prices is displayed and so that grid lines are drawn at "nice" values. For example, when stock prices range from 7500 to 13010, eight grid lines should be displayed at 7000, 8000, 9000, 10000, 11000, 12000, 13000, and 14000. Yet when a stock price ranges from 160 to 426, seven grid lines should be drawn at values 150, 200, 250, 300, 350, 400, and 450. More formally, we want the following requirements met: Grid lines for a plot must be drawn at even increments that are multiples of some fixed M, chosen for the given data set. That value of M must be of the form c * 10 ^ k where c is either 1, 2, or 5 and where k can be any integer. The lowest grid value must be equal to the greatest multiple of M that is less than or equal to low. The highest grid value must be equal to the lowest multiple of M that is greater than or equal to low. There must be at least 5 grid values and at most 10. Write a function of the form v = computeGrid(low,high) that returns a vector v of the grid values that should be used when plotting stocks that range from low to high. For example, computeGrid(7500, 13010) could return the vector [7000 8000 9000 10000 11000 12000 13000 14000] based on increment of M=1000, whereas computeGrid(160, 426) could return the vector [150 200 250 300 350 400 450] based on an increment of M=50. For this problem, you may assume that a solution exists for some M 1. That is, you may assume that k 0 in our notation.

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

List and explain the types of scales.

Answered: 1 week ago

Question

What is digital literacy? Why is it necessary?

Answered: 1 week ago