gpt4 book ai didi

matlab - 带通实现matlab

转载 作者:太空宇宙 更新时间:2023-11-03 20:06:31 25 4
gpt4 key购买 nike

我有 2 个原始信号 X 和 Y 测量旋转轴在常量下的振动。速度 633.33 赫兹。我的目标是只提取特定的频率分量(比如 1X 或 .35X)并为它们绘制轨道(X 信号针对 Y 信号绘制)。我获取原始信号并使用巴特沃斯滤波器应用低通滤波器。它在时域给了我平滑的信号。现在,当我尝试在频率(630 Hz 至 640 Hz)之间应用巴特沃斯带通滤波器时,它无法正常工作。我不知道我做的对不对。下图是应用低通滤波器(巴特沃斯)后的效果。

enter image description here

这是我应用巴特沃斯低通和带通滤波器后的另一个结果。原始信号完全改变。

enter image description here我希望滤波器能为 1X 频率分量做这样的事情,使轨道更清洁。

enter image description here

我的MATLAB代码如下。

  L = length(X); % length of signal
fs= 2e6; % sampling frequency
df = fs/L; % Frequency window
dt = 1/df; % time window
%calculate time axis
T = (0:dt:(L-1)*dt)';
subplot(3,2,1);
plot(T,X);
title('before filtering X signal')
subplot (3,2,2);
plot(T,Y);
title('before filtering Y signal')
subplot(3,2,5);
plot(X,Y);
title('Orbits before filtering')
X = detrend(X,0); % Removing DC Offset
Y = detrend(Y,0); % Removing DC Offset

% Butterworth low pass filter to remove high frequency components
[b2,a2] = butter(6,5*633/(fs/2),'low');
dataInX = X;
X = filter(b2,a2,dataInX); %filter command filters
dataInY = Y;
Y = filter(b2,a2,dataInY);

% butter worth band pass to only plot for 1X frequency component
[b1,a1] = butter(1,[633/(fs/2) 640/(fs/2)],'bandpass');
dataInX = X;
X = filter(b1,a1,dataInX); %filter command filters
dataInY = Y;
Y = filter(b1,a1,dataInY);

subplot(3, 2 ,3);
plot(T,X);
axis tight
title('X signal after filtering')
subplot(3,2,4);
plot(T,Y);
axis tight
title('Y signal after filtering')
subplot(3,2,6);
plot(X,Y);
title('Orbit after filtering')
axis tight

我还附上了我的 data file以供引用。

我是滤波器和 DSP 领域的新手。有人可以通过建议、提示或想法帮助解决这个问题。

最佳答案

低通信号后(即 [b2,a2] = butter(6,5*633/(fs/2),'low');)你可以将采样从 2 MHz 降低到 ~ 4 kHZ 并且不会看到太多结果的变化。在这种情况下,下采样不会改变过滤器尚未降低的任何分辨率。

你可以。在应用低通后,使用 resample(x,1,500) 将 2 MHz 信号下采样到 4 kHz。那么你的窄带通应该没有问题。确保将新的采样率传递到过滤器。

此外,如果您有可用的完整信号,请使用 filtfilt 而不是 filt 以避免相位失真。在这种情况下,您可以稍微降低滤波器阶数,但低通和带通(重采样后)的四阶应该可以正常工作。

关于matlab - 带通实现matlab,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29111768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com