标记一下点

标记一下点_第1张图片

clear
clc
close all
frequency=0.5;
fs=100;
time=(1/fs:1/fs:2*60*100/fs)';
signal=2*sin(2*pi*frequency*time)+3*cos(2*pi*2*frequency*time)+...
    rand(length(time),1);
figure(1)
plot(time,signal)

pwel.window=length(time);
pwel.noverlap=pwel.window/2;
[pxx,f]=pwelch(signal,pwel.window,pwel.noverlap,[],fs);
figure(2)
plot(f,pxx)
xlim([0 2])

% 找到功率谱密度图中的峰值点
[pks, locs] = findpeaks(pxx);

array=[locs,pks];
tf=find(array(:,2)>50)
array1=array(tf,:)

for II=1:length(array1(:,1))
x_f=f(array1(II,1));
x_A=array1(II,2);
txt_f=round(x_f,4)
text(x_f,x_A,num2str(txt_f))
end

你可能感兴趣的:(matlab)