File Exchange

image thumbnail


version 1.0 (1.49 KB) by

To calculate the full-width at half-maximum of an input.

36 Ratings



View License

width = fwhm(x,y)

Full-Width at Half-Maximum (FWHM) of the waveform y(x) and its polarity.

The FWHM result in 'width' will be in units of 'x'

The code was developed by an unknown author.

Comments and Ratings (43)

useful, thx!

riad didou

i have 5 pulse in my signal to find FWHM for every pulse?

Thanks in advance

Kirk Truax

Paul Bebb

is there a reason why the widths come out negative?


418 (view profile)


Can this be extended to find out FWHM of multiple culrves in a single plot and compare between the FWHM? If so, how?

this code is not working for raised sine and raise cosine functions.

Add the following line to handle data with a narrow dynamic range (insert at line 12).

y = y - min(y); %need to subtract off minimum to span [0 1]


BNeto (view profile)

Great! Quite happy with it.

Rick Hsieh

cai jason


Matthew Lee

When I try to take columns out of my array into fwhm - e.g. fwhm(peak(:,1),peak(:,2)) - I am getting an error saying that max is undefined for 'datasets'. So there is an error in y = y / max(y).

Sorry, I have no experience with MatLab. Any help would be greatly appreciated!

Thank you for sharing :)

I'm trying to use this on spectral data from FTIR and I'm getting the error " Attempted to access y(132); index out of bounds because numel(y)=131."

My data is 131 points. Can anyone help me figure out how to use this? I'm very inexperienced with Matlab

Thanks man :)


Joao (view profile)

so good


thanks a lot. Finally I have got the result.


Bob (view profile)

Works as advertised, a great improvement over the simple algorithm for FWHM I was using.

Jade He

Thank you.


Eric (view profile)

the code is perfect, thanks a lot

yongbiao shi



Brilliant, saved me a lot of time!


Robert (view profile)


Donald (view profile)

Simple and easy to read. I modified it to search for the falling edge from the end of the array instead of from the peak because my pulses have high overshoot at the rising/falling edges.

Tom Phillips


Amr Sadek

very easy to use, thank you


Brian (view profile)

Need to add y=y-min(x) at beginning to find fwhm of data not going to zero

Nathir Rawashdeh

It does not work for noisy y(x). It keeps saying the peak is an impulse.

John Smith


bioguider bioguider

easy to use

Ketki V

Fantastic! Im so glad I found this!

Rajiv Bharadwaj

Great Job !

Sue S

Very easy to use!

Igor K

great job!

zm o

This file's suitable to use for experimental datas.


1) Remove line:
[c_max,k_index] = max(y);

2) Replaced two two "if-end" conditions by "if-else-end" condition

3) The output argument "c" was never returned, hence it has been removed.

1) Remove line:
[c_max,k_index] = max(y);

2) Replaced two two "if-end" conditions by "if-else-end" condition

3) The output argument "c" was never returned, hence it has been removed.

MATLAB Release
MATLAB 6.5 (R13)

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video