发布网友 发布时间:2022-05-23 03:40
共1个回答
热心网友 时间:2023-10-12 03:01
有一个问题就是应当对信号整周期截取,以免频率泄露
clear all;
close all;
F1 = 50;
T = 10/F1;
fs = 1000;
N = T*fs;
t = (0:N-1)/fs;
A1 = 100*sin(2*pi*F1*t);
subplot(211);plot(t,A1);
mag1 = abs(fft(A1));
mag = mag1/(N/2);
f = (0:N-1)/N*fs;
subplot(212);plot(f(1:N/2),mag(1:N/2));
[Peak1,i]=max(mag(1:N/2));
fp=f(i);
fprintf('f1=%f,A1=%f\n',fp,Peak1);