Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Matlab Code. I just need help with parts 4 and 5. The vectors below contain prices in dollars of three different stocks. The prices indicate
Matlab Code. I just need help with parts 4 and 5.
The vectors below contain prices in dollars of three different stocks. The prices indicate the stock value each day for 10 days. Stock1 = [4 12 22 39 39 7 39 39 20 33] Stock2 = [6 17 37 32 39 27 2 34 38 28] Stock3 = [31 30 16 277 29 2 12 2 4] 1. Determine the number of days each stock was the lowest for the day. If two stocks are the same price on the same day, neither is the lowest. Output using fprintf. 2. Determine the number of days stock 1 was below one of the other stocks. Output using fprintf. 3. Determine the number of days stock 2 was less than stock 1 but above stock 3. Output using fprintf. 4. You buy 20 shares of stock 2 on Day 1. You sell all of your shares on Day 8. Calculate your profit (number of shares * (selling price - buying price)). 5. Based on your profit use conditional statements to output whether you gained money, lost money, or broke even. (Eg. If you bought stock X on day X and sold on day X you would lose $XXX.XX.) Make sure you use variables properly. If you find yourself typing the same value multiple places, replace it with a variable. While your code should be written with the stock prices above, it should be able to run correctly for any arbitrary stock prices for stock1, stock2, and stock3 over an arbitrary number of days (i.e. If I give any other vectors to those three variables, your code should still give correct answers.)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