Orientations are exported as plain ASCII files, which keeps them readable by any other software. This page is the counterpart of Importing Crystal Orientations.
As an example we take a random sample from a model ODF.
cs = crystalSymmetry.load('quartz.cif');
odf = unimodalODF(orientation.byEuler(30*degree,50*degree,10*degree,cs), ...
'halfwidth',10*degree);
ori = odf.discreteSample(100)ori = orientation (Quartz → y↓→x)
size: 100 x 1Exporting Euler Angles
The command export writes the orientations into an ASCII file. By default the three Bunge Euler angles are written in degree, preceded by a header line naming the columns.
fname = fullfile(tempdir,'orientations.txt');
export(ori,fname)Let us look at the beginning of the resulting file
fid = fopen(fname);
for k = 1:4, disp(fgetl(fid)); end
fclose(fid);phi1 Phi phi2
216.671 113.178 233.492
220.818 139.367 237.496
217.929 121.963 241.686Other Conventions and Units
Any of the Euler angle conventions described in Defining Rotations may be used instead, and the angles may be written in radians rather than in degree.
export(ori,fname,'Matthies','radians')
fid = fopen(fname);
for k = 1:4, disp(fgetl(fid)); end
fclose(fid);alpha beta gamma
2.21083 1.97532 5.646
2.28321 2.43241 5.71589
2.23279 2.12866 5.78901Passing the option quaternion writes the four quaternion components instead of Euler angles. This is the only one of the formats on this page that involves no angle conversion at all.
export(ori,fname,'quaternion')
fid = fopen(fname);
for k = 1:3, disp(fgetl(fid)); end
fclose(fid);a b c d
0.388809 -0.825764 0.12209 0.389917
0.227067 -0.927874 0.136008 0.262664Exporting Additional Properties
Often one wants to store more than the orientations alone - weights, grain sizes, or any other per orientation quantity. A struct passed to export is appended as additional columns, one per field, using the field names as column headers.
S.angle = ori.angle ./ degree;
S.weight = ones(size(ori)) ./ length(ori);
export(ori,fname,S)
fid = fopen(fname);
for k = 1:3, disp(fgetl(fid)); end
fclose(fid);phi1 Phi phi2 angle weight
216.671 113.178 233.492 78.1761 0.01
220.818 139.367 237.496 58.7177 0.01The VPSC Format
Individual orientations are exported to the format expected by the VPSC code with export_VPSC. It always writes Euler angles together with a weight column, normalised to sum up to one.
fnameVPSC = fullfile(tempdir,'orientations_vpsc.txt');
export_VPSC(ori,fnameVPSC)
fid = fopen(fnameVPSC);
for k = 1:4, disp(fgetl(fid)); end
fclose(fid);texture exported by MTEX
B 100Weights differing from orientation to orientation are passed with the option weights.
export_VPSC(ori,fnameVPSC,'weights',rand(size(ori)))Note that a whole ODF, rather than a list of individual orientations, is exported by the commands discussed in ODF Export.
% clean up the temporary files
delete(fname); delete(fnameVPSC);