# Power spectrum of rough surfaces

Does anyone know how to calculate the power spectrum density of rough surfaces in Matlab?

Editor-in-Chief, PhD (Tribology), Researcher at ASML, Eindhoven, the Netherlands. Expertise in modeling of lubrication, friction and wear.

1. I have developed a code in MATLAB for power spectrum analysis using FFT algorithm. This is working well, I am using it for characterizing surfaces measured using stylus, optical, or AFM based profilometry techniques. Please write me in e-mail for further details.

2. It’s the FFT of the autocorrelation function, in python (free for everyone, just as good as matlab, way more popular in the wider world):
import scipy.signal
import numpy as np
# profile is the surface profile
# grid_spacing is the profile grid spacing in whatever unit you like
# (frequencies will be in the same unit)
x=profile.shape[0]
y=profile.shape[1]
acf=scipy.signal.correlate(profile,profile,’same’)/(x*y)
psd=np.fft.fft2(acf)
# The frequencies in the x an y direction are given by:
x_f=np.fft.fftfreq(profile.shape[0], grid_spacing)
y_f=np.fft.fftfreq(profile.shape[1], grid_spacing)