Time-aligning two signals to be out of phase for optimal cancelation
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have two signals of the same length that are fairly identical to each other as shown in the image below. Each signal can be named s1 and s2 respectively. I'm looking to time-align these two signals in such a way that s1 and s2 are out of phase with each other so that when they are added together, they have the greatest possible cancelation.
I've used the following code to time-align these signals,
[acor,lag] = xcorr(s2,s1);
[~,I] = max(abs(acor));
lagDiff = lag(I);
however, when I shift s1 in time using the value of lagDiff, s1 and s2 are not out-of-phase like I would like them to be. This is to be expected with my current code so I know that isn't the real problem. I've used for-loops in the past to try and get around this, but I've found they take up too much computation time and can be somewhat cumbersome with a high number of samples in a signal.
If there was a quicker way to more closely match the amplitudes of s1 and s2 than by using a for-loop, that would be great too.
0 commentaires
Réponses (1)
Suze Zhang
le 21 Sep 2017
Hi Trent,
Have you considered to try function "alignsignals" from Signal Processing Toolbox? Here is the documentation link with examples:
If this does not meet your goal for aligning these two signals, you can also consider to use "parfor" from Parallel Computing Toolbox to execute the for-loop in parallel to save computation time.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!