Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Problem 1128. Simple return on investment

Created by Mehmet OZC

Assume you have some money and want to invest all your money to stock market. You randomly select a stock and invest all your money to that stock at time t. After n days you sell all your stocks from t+n price. What is your return in percent? Round results to two decimal places.

Take as an example, the closing prices of stock X;

 closing_prices = [721;702;703;698;692;705;714;729;735;750];
 return = (price(t+n)-price(t))/price(t) = (750-721)/721 = 4.02%

It is also assumed that you operate with closing prices!


Problem Group

Solution Statistics

62 correct solutions 52 incorrect solutions
Last solution submitted on Mar 11, 2016