count the number of new listings and delistings across time

2 次查看(过去 30 天)
Dear there, Happy Christmas. Could you gift me by helping me to solve my problem:) haha.
I have the following price matrix, with rows for time from date 1 to date 7 and columns for 5 assets. The values available in each column means the asset is traded on the market. For asset 1, it is listed on date 4 and is delisted on date 6. Asset 2 is listed on date 1 and not listed. Asset 3 is listed on date 1 and listed on date 4...so on...I want to know to summarize how many assets are newly listed and how many are just right delisted from the market over time.The result is expected be two vectors,one is new=[2 0 1 1 0 1 0] and the other is new delisting=[0 0 0 1 0 1 0].
Thank you very much. I am waiting online for your answers.
p2 =
NaN 2 4 NaN NaN
NaN 1 1 NaN NaN
NaN 3 1 1 NaN
1 4 NaN 1 NaN
2 2 NaN 2 NaN
NaN 1 NaN 3 2
NaN 1 NaN 4 2

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2015-12-24
p2 =[ NaN 2 4 NaN NaN
NaN 1 1 NaN NaN
NaN 3 1 1 NaN
1 4 NaN 1 NaN
2 2 NaN 2 NaN
NaN 1 NaN 3 2
NaN 1 NaN 4 2]
ii=~isnan(p2);
new=sum([ii(1,:) ;diff(ii)]==1,2)
new_delesting=sum([ii(1,:) ;diff(ii)]==-1,2)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by