tongqingliu

保持学习的态度

Matlab用mpeaks函数求峰值点坐标

clear;clc;close all
% 初始化
m = [-6,-2,0,2,4,6];
sigma = [1,1,0.5,0.25,0.6,2];
h = [1,2,3,2,2.13,3.14];
x=-10:0.01:10;
sumy = zeros(1,length(x));
% 绘制各分支高斯信号
figure;
for i = 1:length(m)
    y=(h(i)/((sqrt(2*pi))*sigma(i)))*exp(-((x-m(i)).^2)/(2*sigma(i).^2));
    y=awgn(y,30,'measured');
    sumy = sumy+y;
    hold on;
    plot(x,y,'LineWidth',1);
end
title('Gaussian Signal add AWGN')
xlabel('x');ylabel('f(x)')
% 绘制叠加高斯信号
figure;
plot(x,sumy,'b','LineWidth',1)
title('Gaussian signal add AWGN')
xlabel('x');ylabel('f(x)')
% mspeaks寻峰,返回的是峰值点坐标
p=mspeaks(x,sumy,'SHOWPLOT',true);

posted on 2017-03-13 13:56  tongqingliu  阅读(2515)  评论(0编辑  收藏  举报

导航