How to smoothly connect two signals in matlab [closed]

℡╲_俬逩灬. 提交于 2019-12-08 08:26:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!