Finding the value of the below curve

1 回表示 (過去 30 日間)
Amy Topaz
Amy Topaz 2022 年 4 月 14 日
回答済み: Star Strider 2022 年 4 月 14 日
z1 = [0.00008 0.009]';
a11 = -2:0.002:2;
k1 = atan(((0.02 + a11)./z1)) + atan((0.03 - a11)./z1);
plot(a11,k1(1,:),'-k',a11,k1(2,:),'-r')
%%How to find the full width at half maximum for k1????

回答 (3 件)

Akira Agata
Akira Agata 2022 年 4 月 14 日
If you have a Signal Processing Toolbox, pulsewidth function will be a simple and effective solution.

Davide Masiello
Davide Masiello 2022 年 4 月 14 日
Hi again @Amy Topaz XD
See below. I have done the procedure for one curve only, so to make it clearer.
z1 = [0.00008 0.009]';
a11 = -1:0.001:1;
k1 = atan(((0.01/2 + a11)./z1)) + atan((0.01/2 - a11)./z1);
% Find max values for both curves
[~,idx_k1] = max(k1,[],2);
% Width at half max for first curve
half_max = k1(1,idx_k1(1))/2;
xq(1) = interp1(k1(1,1:idx_k1),a11(1:idx_k1), half_max);
xq(2) = interp1(k1(1,idx_k1+1:end), a11(idx_k1+1:end), half_max);
% Width at half max
L = xq(2)-xq(1);
% Plotting
plot(a11,k1(1,:),'-k',a11(idx_k1(1)),k1(1,idx_k1(1)),'*b')
hold on
plot(xq, [1 1]*half_max, 'r')
plot(xq, [1 1]*half_max, 'xr', 'MarkerSize',10)
text(xq(1)+L/2,0.9*half_max,'L','HorizontalAlignment','center','Color','red')
axis([-0.05 0.05 -inf +inf])

Star Strider
Star Strider 2022 年 4 月 14 日
Using findpeaks
z1 = [0.00008 0.009]';
a11 = -2:0.002:2;
k1 = atan(((0.02 + a11)./z1)) + atan((0.03 - a11)./z1);
[pk1,loc1,wdth1] = findpeaks(k1(1,:),a11, 'WidthReference','halfheight');
[pk2,loc2,wdth2] = findpeaks(k1(2,:),a11, 'WidthReference','halfheight');
fprintf('Width k1(1,:) = %.6f\nWidth k1(2,:) = %.6f\n',wdth1,wdth2)
Width k1(1,:) = 0.050004 Width k1(2,:) = 0.053169
.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by