フィルターのクリア

How to find the width of a peak where there is no actual data, just individual points?

4 ビュー (過去 30 日間)
I am trying to obtain the width at the half maximum location of the peak displayed in the figure. I have already found the location of the half max and have depicted it with dotted lines. Now, I would like to calculate the width inside that peak at the specified height. I would just get the intercept of the blue line and the dotted line and calculate it but since there is no actual data in the blue line, just a straight line connecting the individual points, I am not sure how to do it.
clear; clc; clf; close all;
xdata = [0 0.012 0.03 0.051 0.08 0.11 0.15];
ydata = [0.060583 0.098032 0.1407 0.40137 0.1407 0.098032 0.060583];
halfMax_y = 0.20069;
maxLocation_x = 0.051;
figure;
plot(xdata, ydata, 'o-');
hold on;
yline(halfMax_y, 'k--');
xline(maxLocation_x, 'k--');
I would like to find this distance, you can assume that the units of the x axis are distance in meters:
If somebody has an idea on how to do it I would really appreciate it. And if it can also be kept as simple as possible because I am a beginner I appreciate it. I have seen a couple peak processing toolbox online but I am not experienced with those options.

採用された回答

David Goodmanson
David Goodmanson 2023 年 6 月 27 日
Hi Alfredo,
Usually your ydata would be the frequency domain version of a linear quantity such as voltage or displacement. Half maximum refers to half of a squared quantity such as power, so it would be down from the peak by a factor of sqrt(2) for the linear quantity. I will arbitrarily assume that here, but if you really intend to drop by a factor of 2 in ydata you can make the appropriate change below.
With this small number of points it seems best to use some spline-type interpolation, which I did with pchip.
xdata = [0 0.012 0.03 0.051 0.08 0.11 0.15];
ydata = [0.060583 0.098032 0.1407 0.40137 0.1407 0.098032 0.060583];
npts = 1000;
xp = linspace(0,.15,npts);
yp = pchip(xdata,ydata,xp);
[ymax,indmax] = max(yp)
halfh = ymax/sqrt(2); % down by sqrt(2)
x1 = xp(1:indmax);
x2 = xp(indmax:end);
y1 = yp(1:indmax);
y2 = yp(indmax:end);
w1 = interp1(y1,x1,halfh);
w2 = interp1(y2,x2,halfh);
fwhm = w2-w1 % full width half max
figure(1);
plot(xdata, ydata, 'o-',xp,yp);
hold on
plot([w1 w2],[halfh halfh],'og-')
hold off
grid minor
ymax = 0.4014
indmax = 341
fwhm = 0.0246

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by