match the date from two files
显示 更早的评论
Hi I am about to perform an event study and I need to calculate abnormal stock returns for about 500 U.S. companies. I have two matrices, one with returns, the other with events. the first column contains dates and the first row the name of company in both matrices. Now I need to find the return on the day of the event for specified company. Could someone help me? I tried to do this with find () but its not working. Thanks in advance for all hints.
回答(2 个)
the cyclist
2013-6-11
I think you should be able to do this with the ismember() command. The syntax will be roughly
[tf,index] = ismember(event(:,1),return(:,1));
The index will tell you which row in return it found the same first column value as it found in the first column of event.
Sean de Wolski
2013-6-11
Use datenum to convert the dates to serial datenumbers if they are not in this form already. Then use ismember to identify dates that are members of both:
doc datenum
doc ismember
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!