Finding the value of the below curve

조회 수: 3 (최근 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 CenterFile Exchange에서 Time Series에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by