VLOOKUP Function (Unique Find For loop)

3 Ansichten (letzte 30 Tage)
Emily Read
Emily Read am 26 Jun. 2019
Beantwortet: Emily Read am 26 Jun. 2019
I am looking at cross-sectional stock returns from 1996 to 2012.
Although there are only 6250 individual/unique dates, there are 17 million dates/rows in my original table, since returns of different stocks correspond to the same date.
I have made a column of the 6250 unique dates in a new table.
I have then made a row of the 10000 unique stock IDs as headers of this new table. I cannot attach such a large file, however, I have print screened how this looks (attached).
I would like the corresponding returns from the original table, to go into this new table, in the correct column/row corresponding to its date and ID number.
So I would like it take the first cell of the date column of the new table, then go along the row of stock IDs one by one. It should look for these two variables in the original table. It should then print the return that it corresponds to, in the new table.
This should then be looped, so that once it has gone through the whole row, it goes down to the second date, then along the row again.
I am very new to matlab, however, I believe a vlookup type function, or find/quality/unique/match function within a 'for' loop, and then perhaps fprintf into the newtable would work.
This is what I have so far:
a = newtable
i=dates
j=IDs
For i=1:1:6250 and j:1:10000
If (a(:,1)==originaltable(:,1) & a((1,:)==originaltable(:,2)
fprintf original table (:,3)
end
I would greatly appreciate any help with this.
I am using R2018a matlab and simulink
Thank you for your time.

Antworten (1)

Emily Read
Emily Read am 26 Jun. 2019

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by