How can I match my dates?

4 views (last 30 days)
Ugur
Ugur on 16 Jul 2013
Hi!
I would like to know which function should I use to match my dates. I have a matrix of 3653X337 (including data for weekends) and a vector of 2609X1 (for dates without weekends. I would like to match the dates in the vector with those of the matrix.
Thanks a lot!
  4 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 16 Jul 2013
do you mean that each week corresponds to 5 days?
Ugur
Ugur on 16 Jul 2013
to be more precise my matrix is composed of 3653 days and 337 companies from different countries and my data is the stock price of each company. As different countries are having different holidays I downloaded the data where I replaced holidays with the last value at the closing of the stock exchange. But I have now in my matrix also the weekends and I don't want to have the weekends. Therefore, I've created a vector for the same period but without the weekends (2609 days) and I want now to match my vector with my matrix in order to have my data without weekends.

Sign in to comment.

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 16 Jul 2013
You can create 3653 days for your data, then remove the weekends from your array.
s1=datenum('01/01/2000','dd/mm/yyyy'); % Example of start day
s2=s1+3653-1;
d=s1:s2;
data=rand(3653,337); % Example of data
v=[d' data];
v(7:7:end,:)=[];
v(6:6:end,:)=[];
  3 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 16 Jul 2013
Edited: Azzi Abdelmalek on 16 Jul 2013
If you have financial toolbox you can use isbusday function
Azzi Abdelmalek
Azzi Abdelmalek on 16 Jul 2013
Edited: Azzi Abdelmalek on 16 Jul 2013
s1=datenum('01/01/2000','dd/mm/yyyy');
s2=s1+3653-1;
d=s1:s2;
idx=not(isbusday(d,[6 7])); % find 6th and 7th day of the week
data=rand(3653,337);
v=[d' data];
v(idx,:)=[];

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!