# 1-dimensional surface roughness power spectrum of a profile or topography

Version 1.6.1.0 (2.98 KB) by
Calculates 1D surface roughness power spectrum for a surface topography/or multiple line profiles
Updated 19 Dec 2016

In surface roughness analysis, one of the powerful tools for roughness characterization is surface roughness power spectrum (PSD). If you have multiple line scans, for examples obtained by stylus profilers, or, if you have a 3D surface topography in which you are interested to calculate power spectrum in x direction and/or in y direction (e.g. to check anisotropy of your surface profile), you need to calculate surface roughness power spectrum for each line profile and then average calculated power spectrums together.
With this function you can calculate 1D PSD of a surface topography or multiple line scans stored in a matrix.
In case of 1D line profiles, store all your lines in one matrix, i.e. if you have ‘n’ measurements where each measurement consists of ‘m’ points, you must first store all your measurements in a matrix with size n*m, called here z, and just use below line to get your calculated 1D PSD for you:
[q , C] = psd_1D(z , PixelWidth , 'x') ;
Be aware that, you need to know you PixelWidth (spatial resolution) which is obtained easily by dividing you measurement length (L) to the number of pixels/points in length (n), i.e. :
PixelWidth = L / n; % in SI units
In case you have a surface topography matrix of size n*m, called here z, you can calculate 1D PSD considering profiles parallel to x axis or y axis. Just use below lines:
[qx , Cx] = psd_1D(z , PixelWidth , 'x') ; % profiles will be z(1,:), z(2,:), ... and so on.
[qy , Cy] = psd_1D(z , PixelWidth , 'y') ; % profiles will be z(:,1), z(:,2), ... and so on.

In order to plot the output:

loglog(q,C)

*** The "Warning: Negative data ignored " is normal and is due to shifting the frequency components to have symmetry with respect to zero frequency.

For 2-dimensional surface roughness power spectrum on surface topographies, refer to:

Radially Averaged Surface Roughness Power Spectrum

Radially averaged surface roughness power spectrum (PSD) only on top or bottom part of a topography

To generate an artificial surface topography to try the code, refer to:

Surface generator: artificial randomly rough surfaces
http://se.mathworks.com/matlabcentral/fileexchange/60817-surface-generator--artificial-randomly-rough-surfaces

### Cite As

Mona Mahboob Kanafi (2024). 1-dimensional surface roughness power spectrum of a profile or topography (https://www.mathworks.com/matlabcentral/fileexchange/54315-1-dimensional-surface-roughness-power-spectrum-of-a-profile-or-topography), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2016a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Categories
Find more on Fourier Analysis and Filtering in Help Center and MATLAB Answers

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.6.1.0

Bug fix.

1.6.0.0

Bug fix.

1.5.0.0

Bug Fix.

1.4.0.0

1.3.0.0

Error handling.

1.2.0.0