Data Analysis - Chapter 17 Data Analysis 17.1 Basic...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 17 Data Analysis 17.1 Basic Statistical Analysis MATLAB has built-in functions for analyzing randomized data as well as the results of deterministic calculations. With respect to m × n arrays of random numbers, the n columns are associated with n specific variables and the m rows in a particular column correspond to m individual outcomes of that variable. The following example includes an array of random data and the examples which follow demonstrate the data analysis capabilities of MATLAB. Daily closing prices for three stocks over a four-week period are given. An array of three columns (one for each stock) and twenty rows (one for each closing price) is created. Example 17.1.1 stock1_wk1=[95+3/8; 97+1/8; 98; 97+5/8; 99+2/8]; stock1_wk2=[99+1/8; 98+4/8; 99+3/8; 98+1/8; 100+1/8]; stock1_wk3=[101+3/8; 102+3/8; 103; 100+5/8; 101+7/8]; stock1_wk4=[103+2/8; 104+1/8; 104+3/8; 103+3/8; 102+5/8]; stock2_wk1=[25+2/8; 30+1/8; 33+1/8; 37+3/8; 40+5/8]; stock2_wk2=[44+4/8; 49+2/8; 53+3/8; 58+6/8; 62+4/8]; stock2_wk3=[53+7/8; 56+5/8; 56+7/8; 57; 59+1/8]; stock2_wk4=[58+3/8; 53+4/8; 46+3/8; 47+2/8; 49]; stock3_wk1=[65+1/8; 62+3/8; 59+4/8; 56+7/8; 58+1/8]; stock3_wk2=[63+2/8; 65+1/8; 65+3/8; 68+3/8; 72+2/8]; stock3_wk3=[83+3/8; 86+7/8; 85+7/8; 80+6/8; 75+4/8]; stock3_wk4=[78+2/8; 79+6/8; 75+7/8; 74+1/8; 72+7/8]; stock1_month=[ stock1_wk1; stock1_wk2; stock1_wk3; stock1_wk4]; % Create % 20 by 1 column vector of stock1 prices for weeks 1 to 4 stock2_month=[ stock2_wk1; stock2_wk2; stock2_wk3; stock2_wk4]; % Create % 20 by 1 column vector of stock2 prices for weeks 1 to 4 stock3_month=[ stock3_wk1; stock3_wk2; stock3_wk3; stock3_wk4]; % Create % 20 by 1 column vector of stock3 prices for weeks 1 to 4 days=1:20; % Create abscissa vector for plotting hold on % Retain plots plot(days,stock1_month,'*:b') % Plot stock1 prices for month plot(days,stock2_month,'*:r') % Plot stock2 prices for month plot(days,stock3_month,'*:g') % Plot stock3 prices for month xlabel('Day Number') ylabel('Price, $') title('Closing Prices for Stocks in February') stocks123_month=[stock1_month, stock2_month, stock3_month] % Create 20 % by 3 array of stock prices 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
stocks123_month = 95.3750 25.2500 65.1250 97.1250
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Data Analysis - Chapter 17 Data Analysis 17.1 Basic...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online