如何在Matlab中平滑连接两个信号 [英] How to smoothly connect two signals in matlab

查看:502
本文介绍了如何在Matlab中平滑连接两个信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要生成两个信号,最后我要连接.问题在于,与我的第二个信号中的初始条件相比,第一个信号的结束条件可能有很大的不同.随后,这可能会导致我的最终信号突然而又不切实际地跳跃.最终信号是2个连接的信号.

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?

谢谢!

推荐答案

如何进行某种交叉渐变:

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.

这篇关于如何在Matlab中平滑连接两个信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆