I have two column vectors [a b] and [c d]. I want to select only those data points in ‘a’where ‘c’ matches to ‘a’ and also corresponding ‘b’ values. As there is some repetition in ‘a’ which is making ‘ismember’ command not to work properly. ‘For loop’ is another option but size of column vectors is too big for making a loop. Just short example is given below. Any solution? Thanks
[a b]
ans =
1.0000 0.1000
2.0000 0.2000
2.0000 0.2000
3.0000 0.4000
4.0000 0.5000
[c d]
ans =
2 7
3 12
If repeated values for
aalways come with the same value forb, you can use the second output ofismemberfor a simple solution:If repeated values for
asometimes can have different values forb(e.g.[2 0.2; 2 0.3], you need to calluniqueonafirst: