当前位置:网站首页>Will signal with different start time alignment

Will signal with different start time alignment

2022-08-10 03:22:00 jk_101

目录

Align signals with different start times        

Remove peaks from the signal


Align signals with different start times        

        Many measurements involve data collected asynchronously by multiple sensors.If you want to integrate signals,They must be synchronized.Signal Processing Toolbox Some functions are provided to achieve this.

        例如,Suppose a car passes over a bridge.The vibrations it produces are measured by three identical sensors located in different locations.Signals have different arrival times.

        Load the signal into MATLAB workspace and draw.

load relatedsig

ax(1) = subplot(3,1,1);
plot(s1)
ylabel('s_1')

ax(2) = subplot(3,1,2);
plot(s2)
ylabel('s_2')

ax(3) = subplot(3,1,3);
plot(s3)
ylabel('s_3')
xlabel('Samples')

linkaxes(ax,'x')

如图所示:

        信号s1落后于s2,but ahead of s3.可以使用finddelayLatency is calculated accurately.可以看到,s2 领先于 s1 350 个样本,s3落后于 s1 150 个样本,而 s2 领先于 s3 500 个样本. 

t21 = finddelay(s2,s1)
t31 = finddelay(s3,s1)
t32 = finddelay(s2,s3)


t21 =

   350


t31 =

  -150


t32 =

   500

        Signals are aligned by keeping the oldest signal stationary and truncating delays in other vectors.Lag needs to be added 1,因为 MATLAB 使用从 1 开始的索引.This method uses the earliest signal arrival time(即 s2 的到达时间)Use as a reference to align the signals.

axes(ax(1))
plot(s1(t21+1:end))

axes(ax(2))
plot(s2)

axes(ax(3))
plot(s3(t32+1:end))

        如图所示:

        使用 alignsignals alignment signal.This function delays older signals,to use the latest signal arrival time(即 s3 的到达时间)作为基准. 

[x1,x3] = alignsignals(s1,s3);
x2 = alignsignals(s2,s3);

axes(ax(1))
plot(x1)

axes(ax(2))
plot(x2)

axes(ax(3))
plot(x3)

        如图所示:

        These signals are now synchronized,available for further processing.

Remove peaks from the signal

        Sometimes there are unwanted transients in the data(即峰值).Median filtering is a good way to get rid of it.

        以存在 60 Hz An example of an open-loop voltage at the input of an analog instrument when there is wire noise.采样率为 1 kHz.

load openloop60hertz

fs = 1000;
t = (0:numel(openLoopVoltage) - 1)/fs;

        Add transients to corrupt the signal by adding random symbols at random points.重置随机数生成器以获得可再现性.

rng default

spikeSignal = zeros(size(openLoopVoltage));
spks = 10:100:1990;
spikeSignal(spks+round(2*randn(size(spks)))) = sign(randn(size(spks)));

noisyLoopVoltage = openLoopVoltage + spikeSignal;

plot(t,noisyLoopVoltage)

xlabel('Time (s)')
ylabel('Voltage (V)')
title('Open-Loop Voltage with Added Spikes')

        如图所示:

yax = ylim;

        函数 medfilt1 Replaces each point of the signal with the median of that point and the specified number of neighbors.因此,Median filtering discards points that are very different from their surroundings.The signal is filtered by computing the median using the set of three neighbors.Notice how the peak disappears.

medfiltLoopVoltage = medfilt1(noisyLoopVoltage,3);

plot(t,medfiltLoopVoltage)

xlabel('Time (s)')
ylabel('Voltage (V)')
title('Open-Loop Voltage After Median Filtering')
ylim(yax)
grid

          如图所示:

原网站

版权声明
本文为[jk_101]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208100201115622.html