【发布时间】:2016-10-16 21:19:41
【问题描述】:
我现在在输出中有最小值和最大值(图 1),但我想为排序的最大值(最高得到 1,...)和最小值(最低得到 1)获取标签(图 2) . 我可以通过以下方式完成图 1 的输出,但我无法将这些注释集成到函数中
close all; clear all; clc;
% https://se.mathworks.com/help/signal/ref/findpeaks.html
% http://stackoverflow.com/a/26837689/54964
x = linspace(0,1,1000);
Pos = [1 2 3 5 7 8]/10;
Hgt = [4 4 2 2 2 3];
Wdt = [3 8 4 3 4 6]/100;
for n = 1:length(Pos)
Gauss(n,:) = Hgt(n)*exp(-((x - Pos(n))/Wdt(n)).^2);
end
PeakSig = sum(Gauss) - exp(sum(Gauss))/10;
plot(x, PeakSig);
hold on;
[p l]=findpeaks(PeakSig); %,x); %,'Annotate','extents','WidthReference','halfheight')
plot(x(l), p, 'ko', 'MarkerFaceColor', 'g');
[pn ln]=findpeaks(-PeakSig); %,x); %,'Annotate','extents','WidthReference','halfheight')
plot(x(ln), -pn, 'ko', 'MarkerFaceColor', 'r');
title('Signal Peak Widths')
仅将'Annotate','extents','WidthReference','halfheight') 附加到[p l]=findpeaks(...) 在应用程序等中不起作用,显然是因为前行plot(x(l), p, 'ko', 'MarkerFaceColor', 'g'); 不理解相应变量中单行器所产生的额外内容
[p l]=findpeaks(PeakSig,'Annotate','extents','WidthReference','halfheight')
[p l]=findpeaks(PeakSig, x, 'Annotate','extents','WidthReference','halfheight')
图。 1 没有这些注释的当前输出, 图 2 预期输出,但带有最大值和最小值的注释
MATLAB:2016b
操作系统:Debian 8.5 64 位
硬件:华硕 Zenbook UX303UA
【问题讨论】:
标签: matlab annotations matlab-figure