Date: Feb 12, 2013 8:43 PM
Author: Derek Goring
Subject: Re: Daily stock returns problem

On Wednesday, February 13, 2013 2:28:10 PM UTC+13, Pallav Mishra wrote:
> I am trying to import commodity futures prices from an XL sheet (filename: CrudeOil.xls..unable to upload the file here since there is no feature to do so. Please find the data pasted below). I am trying to calculate daily, weekly and monthly stock returns from the data in the file using xlsread and plot the data but it is giving me Datenum Failed error (Error using dtstr2dtnummx Failed on converting date string to date number).[Formula for daily stock: log(Price(n)/Price(n-1))]. Could someone please help me find alternative methods of doing this - without getting datenum bugs?
>
>
>
> I have tried [num,txt,raw] = xlsread('CrudeOil.xls');
>
>
>
> Data of CrudeOil.xls :-
>
>
>
> Date Price 01/02/90 22.88 01/03/90 23.81 01/04/90 23.41 01/05/90 23.07 01/06/90 21.64 01/07/90 22.25 01/08/90 22.9 01/09/90 23.15 01/10/90 23.17 01/11/90 22.36 01/12/90 22.61 01/13/90 22.11 01/14/90 22.78 01/15/90 23.7 01/16/90 22.57 01/17/90 22.34 01/18/90 23.43 01/19/90 24.48 01/20/90 22.56 01/21/90 22.79 01/22/90 22.29 01/23/90 22.69 01/24/90 22.71 01/25/90 23.04 01/26/90 22.44 01/27/90 22.36 01/28/90 22.4 01/29/90 22.11 01/30/90 21.82 01/31/90 22.02 02/01/90 21.88 02/02/90 22.12 02/03/90 22.86 02/04/90 22.46 02/05/90 22.46 02/06/90 22.2 02/07/90 21.87 02/08/90 21.4 02/09/90 21.13 02/10/90 21.81 02/11/90 21.62 02/12/90 21.55 02/13/90 21.19 02/14/90 21.36 02/15/90 21.62 02/16/90 21.3 02/17/90 20.93 02/18/90 20.8 02/19/90 20.42 02/20/90 20.26 02/21/90 20.15 02/22/90 20.07 02/23/90 20.38 02/24/90 20.09 02/25/90 19.6 02/26/90 19.34 02/27/90 19.59 02/28/90 19.85 03/01/90 20.28
>
> 03/02/90 20.48 03/03/90 20.36 03/04/90 20.09 03/05/90 20.03 03/06/90 20.34 03/07/90 20.51 03/08/90 20.23 03/09/90 19.78 03/10/90 19.48 03/11/90 19.15 03/12/90 18.32 03/13/90 17.56 03/14/90 18.19 03/15/90 17.76 03/16/90 17.87 03/17/90 17.37 03/18/90 16.95 03/19/90 17.93 03/20/90 17.9 03/21/90 18.6 03/22/90 17.85 03/23/90 17.49 03/24/90 18.5 03/25/90 18.57 03/26/90 18.5 03/27/90 18.76 03/28/90 18.63 03/29/90 17.98 03/30/90 17.98 03/31/90 18.3 04/01/90 18.26 04/02/90 19.01 04/03/90 19.03 04/04/90 18.96 04/05/90 19.73 04/06/90 19.52 04/07/90 19.05 04/08/90 18.89 04/09/90 18.78 04/10/90 18.26 04/11/90 17.51 04/12/90 16.25 04/13/90 16.02 04/14/90 16.12 04/15/90 18 04/16/90 17.88 04/17/90 17.47 04/18/90 17.51 04/19/90 17.09 04/20/90 16.41 04/21/90 16.91 04/22/90 16.65 04/23/90 16.78 04/24/90 16.82 04/25/90 17.39 04/26/90 17.6 04/27/90 17.11 04/28/90 16.64 04/29/90 15.92 04/30/90 15.55
>
> 05/01/90 15.43 05/02/90 16.09 05/03/90 16.5 05/04/90 16.15 05/05/90 17.12 05/06/90 16.7 05/07/90 17.18 05/08/90 17.05 05/09/90 16.94 05/10/90 16.73 05/11/90 16.73 05/12/90 16.5 05/13/90 16.49 05/14/90 16.63 05/15/90 17.05 05/16/90 17.45 05/17/90 18.69 05/18/90 18.37 05/19/90 18.67 05/20/90 18.23 05/21/90 18.57 05/22/90 19.07 05/23/90 19.61 05/24/90 19.88 05/25/90 19.84 05/26/90 19.33 05/27/90 20.33 05/28/90 20.07 05/29/90 20.24 05/30/90 20.57 05/31/90 21.59 06/01/90 23.71 06/02/90 23.79 06/03/90 28.73 06/04/90 29.6 06/05/90 26.19 06/06/90 25.69 06/07/90 26.38 06/08/90 27.07 06/09/90 26.7 06/10/90 26.54 06/11/90 27.4 06/12/90 28.65 06/13/90 28.63 06/14/90 28.46 06/15/90 30.52 06/16/90 31.67 06/17/90 31.1 06/18/90 27.36 06/19/90 27.73 06/20/90 26.15 06/21/90 26.96 06/22/90 27.45 06/23/90 27.45 06/24/90 29.3 06/25/90 30 06/26/90 31.51 06/27/90 30.09 06/28/90 30.83 06/29/90 30.29
>
> 06/30/90 30.85 07/01/90 31.2 07/02/90 31.79 07/03/90 33.73 07/04/90 33.48 07/05/90 33.18 07/06/90 34.44 07/07/90 36.21 07/08/90 39.05 07/09/90 38.33 07/10/90 39.12 07/11/90 39.77 07/12/90 39.53 07/13/90 37.08 07/14/90 34.43 07/15/90 37.04 07/16/90 36.76 07/17/90 37.87 07/18/90 38.88 07/19/90 40.73 07/20/90 39.3 07/21/90 41.07 07/22/90 39.42 07/23/90 38 07/24/90 39.34 07/25/90 36.03 07/26/90 37.03 07/27/90 33.82 07/28/90 28.46 07/29/90 29.95 07/30/90 30.8 07/31/90 34.35 08/01/90 33.03 08/02/90 35.28 08/03/90 34.93 08/04/90 35.31 08/05/90 35.3 08/06/90 33.95 08/07/90 32.05 08/08/90 32.41 08/09/90 35.48 08/10/90 35.61 08/11/90 33.91 08/12/90 32.08 08/13/90 33.3 08/14/90 31.18 08/15/90 31.05 08/16/90 29.91 08/17/90 31.45 08/18/90 29.5 08/19/90 30.08 08/20/90 30.08


But you've only told us half the story..........
After you've read the data into Matlab using xlsread, what do you do next?
This is crucial to finding where the error is occurring.
datenum is a very forgiving function, so you must be trying to do something seriously wrong with it.