# 局所最小値の並び替えを行いたい

5 views (last 30 days)
yuta on 6 Jul 2022
Commented: yuta on 9 Jul 2022

x = linspace(0,1,1000);
Pos = [1 2 3 5 7 8]/10;
Hgt = [3 4 4 2 2 3];
Wdt = [2 6 3 3 4 6]/100;
for n = 1:length(Pos)
Gauss(n,:) = Hgt(n)*exp(-((x - Pos(n))/Wdt(n)).^2);
end
PeakSig = sum(Gauss);
[psor,lsor] = findpeaks(PeakSig,x,'SortStr','descend');
psor
psor = 1×6
4.2603 4.0000 3.2552 3.0039 2.2135 1.9994
lsor
lsor = 1×6
0.2983 0.2002 0.1011 0.7998 0.7057 0.5005

lsorの様に局所的最小値のx軸の数値も抽出したいのですが、うまくいきません。

Shunichi Kusano on 7 Jul 2022

この場合はベース（元のゼロ値）が最大値になるので、プロミネンスを上手く設定するなどして、所望の結果を得ることができるかと思います。

x = linspace(0,1,1000);
Pos = [1 2 3 5 7 8]/10;
Hgt = [3 4 4 2 2 3];
Wdt = [2 6 3 3 4 6]/100;
for n = 1:length(Pos)
Gauss(n,:) = Hgt(n)*exp(-((x - Pos(n))/Wdt(n)).^2);
end
PeakSig = sum(Gauss);
[psor,lsor] = findpeaks(-PeakSig,x,'SortStr','descend','MinPeakProminence',0.3);
psor
psor = 1×5
-0.0001 -0.0011 -1.3372 -1.8394 -2.1344
lsor
lsor = 1×5
0.4024 0.5866 0.1311 0.7397 0.2573
% オプション(0付近の最小値を除きたい場合)
wantedIdx = psor<-0.05;
psor = psor(wantedIdx);
lsor = lsor(wantedIdx);
% 可視化
figure;
plot(x,PeakSig);
hold on;
plot(lsor,-psor,'ro');
text(lsor+.02,-psor,num2str((1:numel(psor))'))
##### 2 CommentsShowHide 1 older comment
yuta on 9 Jul 2022
2つも方法をご教示いただきまして、ありがとうございます。解決いたしました！

### Categories

Find more on スペクトル推定 in Help Center and File Exchange

R2022a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!