问题
I need to generate two signals which in the end I want to connect. The problem is that the end condition of the 1st signal can be quite different compared to the initial conditions in my 2nd signal. Subsequently it can result in a sudden and unrealistic jump in my final signal. Final signal is the 2 connected signals.
How could I smooth the connection in my final signal?
Thanks!
回答1:
What about some sort of cross-fading:
S1 = rand(1000,1);
S2 = rand(1000,1) + 1;
%\\ cross-fade over last 200 elements
n = 200;
W = linspace(1,0,n)'; %'
S1(end-n+1:end) = S1(end-n+1:end).*W;
S2(1:n) = S2(1:n).*(1-W);
S12 = zeros(size(S1,1) + size(S2,1) - n, 1);
S12(1:size(S1,1)) = S1;
S12(end-size(S1,1)+1:end) = S12(end-size(S1,1)+1:end) + S2;
This was using a linear weighting for the fading, you might choose something else but I think this will sort of work.
来源:https://stackoverflow.com/questions/23012679/how-to-smoothly-connect-two-signals-in-matlab