File Exchange

image thumbnail

Matlab2Gwyddion

version 1.1.0.0 (538 KB) by Jens Brauer
Save Matlab data from SPM/AFM scans for use with Gwyddion

5 Downloads

Updated 16 Apr 2016

View Version History

GitHub view license on GitHub

What is Gwyddion?
"Gwyddion is a modular program for SPM (scanning probe microscopy) data visualization and analysis. Primarily it is intended for analysis of height fields obtained by scanning probe microscopy techniques (AFM, MFM, STM, SNOM/NSOM) " (http://gwyddion.net/)
saveasgsf saves a NxM Matrix in the Gwyddion Simple Field file format (.gsf) (one Channel only)

saveasgwy saves a NxM or NxMxL Matrix in the Gwyddion native file format (.gwy)

Function call:
saveasgsf(filename,data,numstepsx,numstepsy,startx,endx,starty,endy,label,unit,time,varargin)
or
saveasgwy(filename,data,numstepsx,numstepsy,startx,endx,starty,endy,label,unit,time,varargin)

Examples:
saveasgsf('test.gsf',rand(30,200),200,30,1,2,3,4,'Chan1','V',now);
saveasgsf('test.gsf',rand(30,200),200,30;
saveasgwy('test.gwy',rand(30,200,2),200,30,1,2,3,4,{'test1','test2'},{'V','m'},now);

Want to help to improve the code?
=> https://github.com/jensb89/Matlab2Gwyddion

Cite As

Jens Brauer (2020). Matlab2Gwyddion (https://github.com/jensb89/Matlab2Gwyddion), GitHub. Retrieved .

Comments and Ratings (4)

arnold

nice one...
I suppose you haven't written a function that imports *.gwy files properly yet?

Dennis Gardner

Just what I needed. Thank you!!

Saravana Kumar

If your scan size is sub micrometer, then replace
nbytes(4)=fprintf(file,'XReal = %f\x0A',abs(endx-startx)/1E6); %µm
nbytes(5)=fprintf(file,'YReal = %f\x0A',abs(endy-starty)/1E6);
nbytes(6)=fprintf(file,'XOffset = %f\x0A',startx/1E6);
nbytes(7)=fprintf(file,'YOffset = %f\x0A',starty/1E6);

with

nbytes(4)=fprintf(file,'XReal = %.15f\x0A',abs(endx-startx)/1E6); %µm
nbytes(5)=fprintf(file,'YReal = %.15f\x0A',abs(endy-starty)/1E6);
nbytes(6)=fprintf(file,'XOffset = %.15f\x0A',startx/1E6);
nbytes(7)=fprintf(file,'YOffset = %.15f\x0A',starty/1E6);

And thanks Jens Brauer !!!

Markus Stiller

very good

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!