Finding the intersection of large vectors using MATLAB

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Finding the intersection of large vectors using MATLAB



How can two signals be compared in MATLAB to find their intersection? My signals are large vectors which can contain duplicate values.



I have been experimenting with the following approach using intersect, which works fine for a randomly generated signals.


intersect


% Example case
sig1 = rand(100,1);
sig2 = [rand(50,1); sig1(end-10:end); rand(50,1)]; % a signal with imposed intersection.
[c, ia, ib] = intersect(sig1, sig2);
plot(sig2)
hold on
scatter(ib, sig2(ib), 'filled')
hold off



I am using this approach for my real data but it does not produce the correct intersection, which is due to duplicate values in the signals. So, I thought to add a very small random noise to both signals and then apply intersect, however, adding a threshold is not possible for intersect.


intersect


intersect



Could someone give me some hints on how the intersection of two large signal measurement can be found robustly and efficiently? Are there other methods? Thank you in advance.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived