How can I match my dates?

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

Do you mean that you have 3653 days?
Ugur
Ugur on 16 Jul 2013
exactly on my matrix I've 3653 days and in my vector I've 2609 days. And I want my data to be according to the days in the vectors.
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)

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

Ugur
Ugur on 16 Jul 2013
the code does not give any error, however, it sometimes delete week days instead of weekends. There is no vlookup function as in Excel?
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
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.

Asked:

on 16 Jul 2013

Community Treasure Hunt

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

Start Hunting!