Oommf vector data file to Matlab array
This is a function to import vector file archives from oommf into Matlab
arrays
Oommf vector files must be written with the output Specifications "text %g"
instead of the default "binary 4" option. And the type of grid must be
rectangular.
Vector files will be imported into the object "data" which will have this
fields:
field: current applied magnetic field
xmin: minimum x value
xnodes: number of nodes used along x
xmax: maximum x value
ymin: minimum y value
ynodes: number of nodes used along y
ymax: maximum y value
zmin: minimum z value
znodes: number of nodes used along z
zmax: maximum z value
datax: component x of vector on data file
datay: component y of vector on data file
dataz: component z of vector on data file
positionx: x positions of vectors
positiony: y positions of vectors
positionz: z positions of vectors
Example:
We have created with Oommf the archive test.omf (included on the zip). To open it into "data"
data=oommf2matlab('test.omf')
Now we can make a 2D vector field
quiver(data.positionx,data.positiony,data.datax,data.datay,0.5)
or calculate the divergence and plot it
div=divergence(data.positionx,data.positiony,data.datax,data.datay);
pcolor(data.positionx,data.positiony,div)
shading flat
colormap bone
For more examples, you can see my blog (look for Oommf, to be updated shortly):
http://thebrickinthesky.wordpress.com/
References:
[1] Oommf Micromagnetic simulator at NIST,
http://math.nist.gov/oommf/
This function was written by :
Héctor Corte
B.Sc. in physics 2010
M.Sc. in Complex physics systems 2012
Ph.D Student between NPL (National Physical Laboratory) and Royal Holloway University of London
London,
United kingdom.
Email: leo_corte@yahoo.es
Cite As
Héctor Corte (2025). Oommf vector data file to Matlab array (https://www.mathworks.com/matlabcentral/fileexchange/44187-oommf-vector-data-file-to-matlab-array), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Acknowledgements
Inspired: Load OOMMF file to Matlab array
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.3.0.0 | There was a problem with 3D data files that now is solved. |
||
1.1.0.0 | An updated version is now available. The older version scan line by line for the data and took 30 s to upload the test.omf file into Matlab, this version uses textscan()and takes only about 0.17 s. |
||
1.0.0.0 |