How to plot this data gained from a for loop?
Show older comments
Should you invest in stocks? We cannot predict the future, but the history tells us some properties of the stock market. Let us calculate the amount of money invested in the Dow Jones Industrial Average (DJIA). Year Percent Gain or Loss
1 1975 38.32%
2 1976 17.86%
3 1977 -17.27%
4 1978 -3.15%
5 1979 4.19%
6 1980 14.93%
7 1981 -9.23%
8 1982 19.61%
9 1983 20.27%
10 1984 -3.74%
11 1985 27.66%
12 1986 22.58%
13 1987 2.26%
14 1988 11.85%
15 1989 26.96%
16 1990 -4.34%
17 1991 20.32%
18 1992 4.17%
19 1993 13.72%
20 1994 2.14%
21 1995 33.45%
22 1996 26.01%
23 1997 22.64%
24 1998 16.10%
25 1999 25.22%
26 2000 -6.18%
27 2001 -7.10%
28 2002 -16.76%
29 2003 25.32%
30 2004 3.15%
31 2005 -0.61%
32 2006 16.29%
33 2007 6.43%
34 2008 -33.84%
35 2009 18.82%
36 2010 11.02%
37 2011 5.53%
38 2012 7.26%
Plot how $1000 invested in DJIA in the beginning of 1975 (or at the end of 1974) would grow over time, until the end of 2012. Your horizontal axis must show the actual calendar year. Scripting Tips: Declare a variable called Year as an array ranging between 1975 and 2012 with an increment of 1 year. Also declare a row vector PG, consisting of percent gains from 1975 to 2012—you need to do some typing here.
Answers (0)
Categories
Find more on Price and Analyze Financial Instruments in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!