How can I replace this:
for i = 1:size(zensus,1) disp(i) for j = 1:size(spezQ,1) if zensus.GBT(i)==spezQ.GBT(j)&&zensus.BJR(i)==spezQ.BJR(j)&&zensus.ZLW(i)==spezQ.ZLW(j) zensus.SQ(i) = spezQ.SQ(j); end endend
with a vectorized version?
I am trying to assign certain values (spezQ) to combinations of categories in my data (zensus).
Any help would be incredible.
Edit: The data looks like this:
zensus: [205240×6]
HZT FLW ZLW HHG GBT BJR SQ 1 1 1 1 1 1 ? 1 1 1 2 2 1 ? 1 1 2 1 1 1 ?
spezQ: [27×4]
GBT BJR ZLW SQ 1 1 1 212,45325 1 1 2 192,6525 1 1 3 183,0135 1 2 2 161,2365
For example: zensus.SQ(1) should be equal to spezQ.SQ(1) because of the matching values of GBT, BJR and ZLW.
My loop takes forever because of the length of zensus. So I am looking for faster code!
Best Answer