MATLAB Answers

How to import AFM data to Matlab?

27 views (last 30 days)
Hivanu I
Hivanu I on 5 Aug 2020
Answered: Kiran Felix Robert on 24 Aug 2020
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

Show 1 older comment
Hivanu I
Hivanu I on 5 Aug 2020
Yes, it's a gwyddion file. So when I'm on gwyddion, I can see the image of the surface and I'd like to export the "Z-Axis foward" values.
Cris LaPierre
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?
Hivanu I
Hivanu I on 7 Aug 2020
I will try! In Gwyddion the image in the backround is the surface of my sample. When I click on Info-->Data Browser, the window in the front shows up and I can choose between the image channels. The other headings just as Graphen (Graphs), Sprektren (Spectra) etc are empty. There are options of exporting the mean values but I need all the original values of the Z-Axis forward channel.
Please excuse my English, I'm trying my best.

Sign in to comment.

Answers (1)

Kiran Felix Robert
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)

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!