Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FWHM with Matlab

497 views
Skip to first unread message

excalibur...@gmail.com

unread,
Apr 16, 2008, 3:57:12 PM4/16/08
to
Hi,
I have an image of a light beam (with a scale bar) and would like
to calculate the FWHM of the latter in Matlab. Does anybody have a
clue on how to do that?


--
Cheers,
Peter.

Dave

unread,
Apr 16, 2008, 8:55:47 PM4/16/08
to


I would suggest you fit a Gaussian to the measured data, then once you
have the parameters of the line of best fit, deducing the FWHM should
not be too hard - just solve for the two points where the signal is half
the maximum.

A Gaussian would be my first thought, but it might be more of a top-hat
profile. How well does a Gaussian fit?

excalibur...@gmail.com

unread,
Apr 17, 2008, 12:28:40 PM4/17/08
to
On Apr 16, 8:55 pm, Dave <f...@coo.com> wrote:

> excalibur.xcali...@gmail.com wrote:
> > Hi,
> > I have an image of a light beam (with a scale bar) and would like
> > to calculate theFWHMof the latter in Matlab. Does anybody have a

> > clue on how to do that?
>
> > --
> > Cheers,
> > Peter.
>
> I would suggest you fit a Gaussian to the measured data, then once you
> have the parameters of the line of best fit, deducing theFWHMshould
> not be too hard - just solve for the two points where the signal is half
> the maximum.
>
> A Gaussian would be my first thought, but it might be more of a top-hat
> profile. How well does a Gaussian fit?

It is a top-hat profile, so how exactly do I do that? :(

jay vaughan

unread,
Apr 17, 2008, 3:18:02 PM4/17/08
to
Before getting too fancy, the easiest thing is to take a
slice through the light beam, plot it and then find the
FWHM manually.

But if you have to get the FWHM many times or need a more
precise (or reproducible) method I would suggest fitting
the beam to a functional form that resembles the beam...my
first guess is to just use a hypergaussian function.

A = 1; % amplitude
x = linspace(-1,1,128);
x0 = 0; % center position
w = .25; % width parameter
n = 3; % squareness parameter
H = A*exp(-((x-x0)./w).^(2*n));
plot(x,H)

For increasing positive integer values of n the function
gets more and more shaped like a top hat and less like a
gaussian. I don't do much fitting in Matlab, but guess you
would want to fit the squareness parameter n in addition to
the usual parameters A, x0, w.

Hope that helps, good luck.
J

excalibur...@gmail.com wrote in message <5d1ab3d5-
de63-4444-ae5...@m3g2000hsc.googlegroups.com>...

elprodigio

unread,
Apr 18, 2008, 11:21:42 AM4/18/08
to
On Apr 17, 3:18 pm, "jay vaughan" <jvaughan5.nos...@gmail.com> wrote:
> Before getting too fancy, the easiest thing is to take a
> slice through the light beam, plot it and then find theFWHMmanually.
>
> But if you have to get theFWHMmany times or need a more

> precise (or reproducible) method I would suggest fitting
> the beam to a functional form that resembles the beam...my
> first guess is to just use a hypergaussian function.
>
> A = 1; % amplitude
> x = linspace(-1,1,128);
> x0 = 0; % center position
> w = .25; % width parameter
> n = 3; % squareness parameter
> H = A*exp(-((x-x0)./w).^(2*n));
> plot(x,H)
>
> For increasing positive integer values of n the function
> gets more and more shaped like a top hat and less like a
> gaussian. I don't do much fitting in Matlab, but guess you
> would want to fit the squareness parameter n in addition to
> the usual parameters A, x0, w.
>
> Hope that helps, good luck.
> J
>
> excalibur.xcali...@gmail.com wrote in message <5d1ab3d5-
>
> de63-4444-ae5b-19dffd3a9...@m3g2000hsc.googlegroups.com>...

>
> > On Apr 16, 8:55 pm, Dave <f...@coo.com> wrote:
> > > excalibur.xcali...@gmail.com wrote:
> > > > Hi,
> > > > I have an image of a light beam (with a scale
> bar) and would like
> > > > to calculate theFWHMof the latter in Matlab. Does
> anybody have a
> > > > clue on how to do that?
>
> > > > --
> > > > Cheers,
> > > > Peter.
>
> > > I would suggest you fit a Gaussian to the measured
> data, then once you
> > > have the parameters of the line of best fit, deducing
> theFWHMshould
> > > not be too hard - just solve for the two points where
> the signal is half
> > > the maximum.
>
> > > A Gaussian would be my first thought, but it might be
> more of a top-hat
> > > profile. How well does a Gaussian fit?
>
> > It is a top-hat profile, so how exactly do I do that? :(

Thanks. Will try that!

---
cheers,
Peter.

0 new messages