MATLAB: How to convrt the FWHM value to picoseconds when given in nanometers for optical gaussian pulses. fwhm I am generating a optical gaussian pulse. I have got the FWHM values in nanometer. I want values in picoseconds. Best Answer Mr Egan has posted in Mathworks website the following function:function width = fwhm(x,y)% function 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'%%% Rev 1.2, April 2006 (Patrick Egan)y = y / max(y);N = length(y);lev50 = 0.5;if y(1) < lev50 % find index of center (max or min) of pulse [garbage,centerindex]=max(y); Pol = +1; disp('Pulse Polarity = Positive')else [garbage,centerindex]=min(y); Pol = -1; disp('Pulse Polarity = Negative')endi = 2;while sign(y(i)-lev50) == sign(y(i-1)-lev50) i = i+1;end %first crossing is between v(i-1) & v(i)interp = (lev50-y(i-1)) / (y(i)-y(i-1));tlead = x(i-1) + interp*(x(i)-x(i-1));i = centerindex+1; %start search for next crossing at centerwhile ((sign(y(i)-lev50) == sign(y(i-1)-lev50)) & (i <= N-1)) i = i+1;endif i ~= N Ptype = 1; disp('Pulse is Impulse or Rectangular with 2 edges') interp = (lev50-y(i-1)) / (y(i)-y(i-1)); ttrail = x(i-1) + interp*(x(i)-x(i-1)); width = ttrail - tlead;else Ptype = 2; disp('Step-Like Pulse, no second edge') ttrail = NaN; width = NaN;endlink: http://uk.mathworks.com/matlabcentral/fileexchange/10590-fwhm/content/fwhm.mWolfram has a table you may find usefullink: http://mathworld.wolfram.com/FullWidthatHalfMaximum.html%20 Hope it helps.Please vote and flag this answer if you find it useful or interesting,thanksJohnjgb2012@sky.com Related SolutionsMATLAB: Save multiple plots to a specific path. for a = 1 : 10 filename = sprintf('S%d.csv', a); Array=csvread(filename,15,0); x = Array(:, 1); y = Array(:, 2); width = fwhm(x,y); outputs = [num2cell(x), num2cell(y)]; outputs{3,1} = width; newfilename = sprintf('Snew%d.csv', a); xlswrite(newfilename, outputs); end MATLAB: The fastest way to find local minimum Invert your signalinvertedSignal = max(signal(:)) - signal;Now valleys will be peaks. Then call find peaks. Related QuestionPeak width calculation methodsEquality of a numeric list using a stringHow to get a Fourier-limited Gaussian pulseHow to make this find function in a for loop run faster using vectorization
Best Answer