MATLAB: HOW TO FIND THE FULL WIDTH AT HALF MAXIMUM

fourier opticsfwhmImage Processing Toolboxpoint spread function

Hi,
I have a problem in the following code:
clear all;
clc;
close all;
lamda=531e-9;
k=2*pi/lamda;
[x,y]=meshgrid(-1*lamda:(2*lamda/127):1*lamda);
r=sqrt(x.^2+y.^2);
w=10^-3;
z=10^-3;
z1=sqrt(w.^2+z.^2);
N.A=w/z1;
v=((k*r));
I=(2*bessel(1,v)./(v)).^2;
I0=max(max(I));
I2=I/I0;
I3=0;
figure(1)
plot(I2(64,:))
%figure(2)
%imagesc(I2),colormap gray
%For full width of airy pattern
% a=19;
% v1=k*w/z;
% d1=a/v1 % d1=1.605*10^-6m;
% For full width at half maximum
b=46;
v2=k*w/z;
d2=b/v2 %d2=6.760*10^-7m;
%%%%%%%%%%%
when you run the above code, you will find figure(1) and I am in need to find the half width full maximum(FWHM) of the said fig. using matlab. It will be a great help for me if anyone help me out in this regard…
Thanking You!

Best Answer

MOHD: First change bessel to besselj like Eric advised. Then add this onto your code.
% Find the max
plot(I2(64,:), 'bo-')
grid on;
oneProfile = I2(64,:);
maxValue = max(oneProfile)
% Find where it's more than half the max.
aboveHalfMax = oneProfile > maxValue/2
% Get the first and last index where it's more than the half max.
firstIndex = find(aboveHalfMax, 1, 'first')
lastIndex = find(aboveHalfMax, 1, 'last')
% Draw lines there
hold on;
line([firstIndex firstIndex], [0 maxValue/2], 'Color', 'r', 'LineWidth', 2);
line([lastIndex lastIndex], [0 maxValue/2], 'Color', 'r', 'LineWidth', 2);
line([firstIndex lastIndex], [maxValue/2 maxValue/2], 'Color', 'r', 'LineWidth', 2);