Question
a. Implement a function that shifts a given vector to the right by k. For example, for the vector [1, 2, 3, 4] the result
a. Implement a function that shifts a given vector to the right by k. For example, for the vector [1, 2, 3, 4] the result for k=1 would be [4, 1, 2, 3] and for k=2 would be [3, 4, 1, 2] (every element shifts to the right k times, if the right boundary is reached the elements go to the left side of the vector). The function (or script) should take a vector and a value of k and return the shifted vector. In your solution, you may not apply the built-in function circshift that shifts arrays in MATLAB, but you can debug your code using that function.
b. You own a computer store that sells laptops of various brands. You are considering giving a 10% discount on the current prices. However, you are worried that if you give the discount you will lose in terms of revenue. You asked a forecasting firm to predict the next months sales (in quantity) with and without the discount. Using the data below, compute the revenues with and without discount, and decide if you will proceed with the discount. You must use vector and/or matrix operations in the solution.
The script should print the revenue before & after and print a Boolean true (1) or false (0) for whether you will give discount or not that will be computed for the specific input. You may solve for the specific example below. Here is the data you need for the analysis:
Prices: Brand | Price Before Discount |
P&H | 1000 |
CAM | 1200 |
LLED | 1100 |
Microhard | 1400 |
Forecasted quantities:
Brand | Quantities before Discount | Quantities after Discount |
P&H | 50 | 51 |
CAM | 100 | 105 |
LLED | 120 | 122 |
Microhard | 30 | 35 |
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