Path: news.mathworks.com!not-for-mail
From: Peter Perkins <Peter.Remove.Perkins.This@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: =?UTF-8?B?UmU6IFdoYXQgaXMgdGhlIGJlc3Qgd2F5IHRvIGltcG9ydCBFeGNlbCA=?=
 =?UTF-8?B?ZmlsZXMsIHdpdGggc3RvY2sgZGF0YSwgaW50byBNYXRsYWI/IEnigJltIHVzaW4=?=
 =?UTF-8?B?ZyBNYXRsYWIgUjIwMTBiICg2NC1iaXQp?=
Date: Thu, 26 Apr 2012 22:06:57 -0400
Organization: The MathWorks, Inc.
Lines: 54
Message-ID: <jncv01$o8m$1@newscl01ah.mathworks.com>
References: <jnc9v7$1ot$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: ah-pperkins.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1335492417 24854 172.31.57.194 (27 Apr 2012 02:06:57 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 27 Apr 2012 02:06:57 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
In-Reply-To: <jnc9v7$1ot$1@newscl01ah.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:766082

On 4/26/2012 4:08 PM, Ryan wrote:
> What is the best way to import Excel files, with stock data, into
> Matlab? I’m using Matlab R2010b (64-bit)
>
> I’m trying to import historical prices of stock data. Matlab keeps
> cutting off the header of each column; it gives me only values. I am
> thinking that this is a data-type-mixing-issue, or whatever it’s called.
>
> I have ‘Dates’ in ColumnA, and ‘MSFT’, ‘PWER’, ‘KO’, and ‘SBUX’, in
> ColumnB-ColumnE.

Ryan, I don't know how you'll want to work with these data after you get 
them into MATLAB, but if you have access to the Statistics Toolbox, this 
kind of file is simple to read with the dataset constructor.  Something like

 >> stocks = dataset('XLSFile','stock_data.xls');
 >> summary(stocks)
Dates: [575x1 cell string]
MSFT: [575x1 double]
     min      1st quartile    median    3rd quartile    max
     23.01    25.37           26.5      28.53           32.85
PWER: [575x1 double]
     min    1st quartile    median    3rd quartile    max
     3.1    4.625           7.43      8.9575          12.78
KO: [575x1 double]
     min      1st quartile    median    3rd quartile    max
     50.03    55.85           64.74     67.767          74.14
SBUX: [575x1 double]
     min     1st quartile    median    3rd quartile    max
     21.7    25.9            33.25     39.888          61.67
 >> stocks(stocks.MSFT>32.5,:)
ans =
     Dates              MSFT     PWER    KO       SBUX
     '3/27/2012'        32.52    4.86    71.87    56.26
     '3/26/2012'        32.59    4.74     71.9    55.91
     '3/16/2012'         32.6    4.69    70.16    53.21
     '3/15/2012'        32.85    4.38    70.33    53.07
     '3/14/2012'        32.77    4.18    70.22    52.68
     '3/13/2012'        32.67    4.39    70.25    52.34
 >> plot(datenum(stocks.Dates),stocks.MSFT,'o')
 >> [y,m] = datevec(stocks.Dates);
 >> stocks.Year = y; stocks.Month = m;
 >> stocks2012 = stocks(stocks.Year==2012,:);
 >> grpstats(stocks2012,{'Year' 'Month'},{'min' 
'max'},'DataVars',{'MSFT' 'PWER'})
ans =
          Year  Month  GroupCount  min_MSFT  max_MSFT  min_PWER  max_PWER
  2012_1  2012      1          20     26.77     29.73      3.98      4.95
  2012_2  2012      2          20     29.89     31.87      4.34      5.51
  2012_3  2012      3          22     31.56     32.85       4.1      4.86
  2012_4  2012      4           9     30.35     32.29      4.06      4.48

And so on.  Hope this helps.