目录
1.低通滤波器滤波信号
clear
clc
close all
% 生成加速度时程信号
fs = 200; % 采样频率为200Hz
duration = 2 * 60; % 时长为2分钟
t = (0:1/fs:duration-1/fs)'; % 时间向量
% 生成白噪声
noise_power = 0.1; % 噪声功率
noise = sqrt(noise_power) * randn(size(t));
% 构造加速度信号
% 这里使用sin函数作为加速度信号的示例,你可以根据需要修改这部分代码
frequency = 1; % 加速度信号的频率
amplitude = 1; % 加速度信号的幅值
acceleration_signal = amplitude * sin(2 * pi * frequency * t);
% 添加白噪声到加速度信号
acceleration_with_noise = acceleration_signal + noise;
% 使用低通滤波器滤除噪声
cutoff_frequency = 3; % 截止频率为10Hz,你可以根据需要调整这个值
[b, a] = butter(10, cutoff_frequency / (fs/2), 'low'); % 4阶低通滤波器设计
filtered_acceleration = filtfilt(b, a, acceleration_with_noise);
% 绘制加速度信号、带噪声的加速度信号和滤波后的加速度信号
figure(1);
subplot(3,1,1);
plot(t, acceleration_signal);
title('Acceleration Signal');
xlabel('Time (s)');
ylabel('Acceleration');
subplot(3,1,2);
plot(t, acceleration_with_noise);
title('Acceleration Signal with Noise');
xlabel('Time (s)');
ylabel('Acceleration');
subplot(3,1,3);
plot(t, filtered_acceleration);
title('Filtered Acceleration Signal');
xlabel('Time (s)');
ylabel('Acceleration');
2.VMD 滤波
clear
clc
close all
filelocation='H:\2.模态测试\程序';
cd(filelocation);
fs=200;
signal=importdata(fullfile(filelocation,'1.断面未滤波衰减时程.xlsx'));
t=1/fs:1/fs:length(signal)/fs;
figure(1)
plot(t,signal)
set(gcf,'Units','centimeters','Position',[1 18 14 8])
imf = vmd(signal);
[p,q] = ndgrid(t,1:size(imf,2));
figure(2)
plot3(p,q,imf)
grid on
xlabel('Time Values')
ylabel('Mode Number')
zlabel('Mode Amplitude')
set(gcf,'Units','centimeters','Position',[15 18 14 8])
figure(3)
plot(p(:,5),imf(:,5))
grid on
xlabel('Time Values')
ylabel('Mode Number')
zlabel('Mode Amplitude')
set(gcf,'Units','centimeters','Position',[29 18 14 8])