Commit 573088ac by TJL233

add files 3

parent 93623126
% Fs = 1000; % 采样率(HZ)
% Fs = 1000; % 采样率(HZ)
% T = 1/Fs; % 采样间隔(秒/S)
L = 300; % 信号长度(毫秒/ms)
% t = (0:L-1)*T; % 时间向量
% x = sin(2*pi*30*t) + sin(2*pi*100*t); %频率分别为30Hz和100Hz的合成信号
[num1, txt1, raw1] = xlsread('123.xlsx');
%原始信号时域表示图
num2=num1(1:300);
f = num2';
t = 1:1:300;
figure(1)
plot(t,f(1:300)) %原始长度1500s,为方便观察,取500ms显示
title('原始信号时域表示')
xlabel('t (毫秒)')
ylabel('x(t)')
%加噪
% s = x + 2*randn(size(t)); %添加均值为0,方差为4的随机噪声
% %含噪信号时域表示图
% %s=x;
% figure(2)
% plot(1000*t(1:500),s(1:500))
% title('含噪信号时域表示:')
% xlabel('t (毫秒)')
% ylabel('x(t)')
%计算频域信息
y = fft(f); %计算信号的傅里叶变换。
P2 = abs(y/L); %取绝对值
P1 = P2(1:L/2+1); %单侧谱
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:L-1)/L;
f1 = Fs*(0:(L/2))/L; %横坐标坐标变换
%信号频谱图
figure(3)
plot(f,P2)
title('含噪信号s(t)的双边谱')
xlabel('f (Hz)')
ylabel('|P1(f)|')
figure(4)
plot(f1,P1)
title('含噪信号s(t)的单边谱')
xlabel('f (Hz)')
ylabel('|P1(f)|')
import numpy as np
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0, 1, 1000)
signal = np.sin(2*np.pi*5*t) + np.sin(2*np.pi*10*t)
plt.plot(t, signal)
plt.show()
fft = np.fft.fft(signal)
fft = np.fft.fftshift(fft)
freqs = np.fft.fftfreq(len(signal), t[1] - t[0])
freqs = np.fft.fftshift(freqs)
plt.plot(freqs, np.abs(fft))
plt.show()
\ No newline at end of file
import pywt
import pywt
import numpy as np
# 定义信号
signal = np.random.rand(32)
# 进行小波变换
wavelet = 'db1' # 选择小波函数
coeffs = pywt.wavedec(signal, wavelet) # 分解信号
# 显示小波系数
print(coeffs)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment