Posts

Showing posts with the label signals

Finding the intersection of large vectors using MATLAB

Image
Clash 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 robu...