How to import AFM data to Matlab?
35 views (last 30 days)
Show older comments
Dear Matlab community!
I have the following problem: I'm measuring a surface with an AFM and analyzing it with Gwyddion. But since the graphic shows a slight bend, I would like to analyze the XYZ-data in Matlab first.
So my question is:
How can I import the XYZ data from Gwyddion to Matlab?
I hope someone can help me out!
Kind regards
4 Comments
Cris LaPierre
on 5 Aug 2020
For those of us who have never seen this file format before, could you perhaps upload a sample along with a description?
Answers (1)
Kiran Felix Robert
on 24 Aug 2020
Hi Hivanu,
There is no direct way to import AFM data from Gwyddion to MATLAB, but MATLAB has option to import csv files using the csvread function or the readmatrix function.
The data imported from a CSV file can be parsed into a matrix and can also be converted in to an image using the image function.
The data in Gwyddion file can be exported to either a CSV file or a .txt file with rows and column containing the required data, which can be parsed in MATLAB and can be saved as an image or used for analysis.
For example, assuming you export a grayscale image data from Gwiddon file which is saved as ‘GwiddonData.csv’, a csv file, then the following example shows one way to import it into MATLAB (Refer mat2gray for more information),
A = readmatrix('GwiddonData.csv');
% To Convert to Grayscale image
I = mat2gray(A);
imshow(I)
1 Comment
George Heath
on 8 Oct 2024
Hi Hivanu,
We have collected togther several MATLAB scripts from various authors to open various AFM image file formats. We have packaged these in a GUI but the MATLAB functions for file opening can be downloaded here:
(go to the functions tab and see the scripts for functions for different file formats, open_nanoscope, open_gwychannel, open_ibw, open_JPK...)
or here:
The open_gwychannel function will open files saved in gwyddion. If you download the script and then run:
[im, meta] = open_gwychannel(filename)
Replacing 'filename' with the filename eg:
[im, meta] = open_gwychannel('Testdata.gwy')
See Also
Categories
Find more on Data Import and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!