Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The arrays price_A,price_B,price_C given below contain the price in dollars of t

ID: 1821569 • Letter: T

Question

The arrays price_A,price_B,price_C given below contain the price in dollars of three stocks over 10 days.
a) Use MATLAB to determine how many days the price of stock A was above both the price of stock B and the price of stock C.
b) Use MATLAB to determine how many days the price of stock A was above either the price of stock B or the price of stock C.

price_A = [19, 18, 22, 21, 25, 19, 17, 21, 27, 29]
price_B = [22, 17, 20, 19, 24, 18, 16, 25, 28, 27]
price_C = [17, 13, 22, 23, 19, 17, 20, 21, 24, 28]

Explanation / Answer

>> price_A = [19, 18, 22, 21, 25, 19, 17, 21, 27, 29]; >> price_B = [22, 17, 20, 19, 24, 18, 16, 25, 28, 27]; >> price_C = [17, 13, 22, 23, 19, 17, 20, 21, 24, 28]; >> part1 = sum((price_A > price_B) & (price_A > price_C)) part1 = 4 >> part2 = sum(xor((price_A > price_B), (price_A > price_C))) part2 = 5 >> The answer to the first part is 4 and to the second part is 9. We do a logical and for the first one and a logical exclusive or for the second (to exclude cases from the first part where it's higher than both B and C). The answer to "how many days is it over the price of stock B, stock C, or both is 9 (5 + 4).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote