⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shipinfenxi2.m

📁 时频分析的一个简单明了的小程序。给出了频率标注时怎样才能精确的显示频率分析的结果
💻 M
字号:
clear all
close all
clc
%generate the time index 
sampling_rate = 100; 
t1 = 0:1/sampling_rate:4-1/sampling_rate; 
t = [t1]; 

%determine the frequency of the input signal 
F1 = 25; 


temp1 = sin(2*F1*pi*t1); 


%generate the signals 
x1 = [temp1]; 

%apply the FFT transform on the input signals 
y1 = fft(x1); 


%plot the input signal 
plot(t, x1); grid on; xlabel('time (seconds)'); ylabel('Magnitude'); 
figure
%generate the frequency index 
f = (0:length(y1)-1)'*sampling_rate/length(y1); 

%plot the frequency components of the input signal 
plot(f(1:length(f)/2), abs(y1(1:length(y1)/2))); 
xlabel('Frequency (Hz)'); ylabel('Abs. Magnitude'); grid on;

sampling_rate = 2000; 
t1 = 0:1/sampling_rate:3-1/sampling_rate; 
t2 = 3+1/sampling_rate:1/sampling_rate:6; 
t = [t1 t2]; 

%determine the frequency of the input signal 
F1 = 500; 
F2 = 600; 
F3 = 700; 
F4 = 800; 

temp1 = sin(2*F1*pi*t1); 
temp2 = sin(2*F2*pi*t2); 
temp3 = sin(2*F3*pi*t1); 
temp4 = sin(2*F4*pi*t2); 

%generate the signals 
x1 = [temp1+temp3 temp2+temp4]; 

%apply the FFT transform on the input signals 
y1 = fft(x1); 

%plot the input signal 
plot(t, x1); grid on; xlabel('time (seconds)'); ylabel('Magnitude'); 
figure
%generate the frequency index 
f = (0:length(y1)-1)'*sampling_rate/length(y1); 

%plot the frequency components of the input signal 
plot(f(1:length(f)/2), abs(y1(1:length(y1)/2))); 
xlabel('Frequency (Hz)'); ylabel('Abs. Magnitude'); grid on;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -