% the following code exports all orientations, one line for each point.
export_VPSC(ebsd('Magnesium').orientations,'filename.txt')
%A more computationally efficient way (eg 691 orientations vs 47672) to export is to threshold into grains, and use the mean orientations. In this case, we must separate out the weights for each orientation, or they are assumed to be equal. We get this information from the grain size
W=grains.grainSize/sum(grains.grainSize)
export_VPSC(grains.meanOrientation,'W56-T0-P7.txt','weights',W)
%to make things even better, we can eliminate all grains with grain size less than a minimum value, say 5 pixels. (now only 44 orientations for VPSC to address)
%to remove all small grains, determine which these are and make a list
%first create a logical to determine what data meets the criteria
temp=grains.grainSize>=5
%then load the conforming data into a new matrix
grainsLG=grains(temp)
%now load the weights for those grains into W
W=grainsLG.grainSize/sum(grainsLG.grainSize)
%and export the data
export_VPSC(grainsLG.meanOrientation,'filename.txt','weights',W)
CS = crystalSymmetry('hexagonal');
texFile = 'TEX_PH1_0p15.txt';
ori_0p15 =loadOrientation_generic(texFile,CS,'ColumnNames',{ 'Euler1','Euler2','Euler3','Error'},'Bunge');
delimiterIn = ' ';
headerlinesIn = 4;
W = importdata(texFile,delimiterIn,headerlinesIn);
W_0p15=W.data(:,4);
texFile = 'TEX_PH1_0p3.txt';
ori_0p3 =loadOrientation_generic(texFile,CS,'ColumnNames',{ 'Euler1','Euler2','Euler3','Error'},'Bunge');
delimiterIn = ' ';
headerlinesIn = 4;
W = importdata(texFile,delimiterIn,headerlinesIn);
W_0p3=W.data(:,4);
plotx2east;
h=[Miller(0,0,1,CS),Miller(1,0,0,CS)];
odf_0p15 = calcODF(ori_0p15,'weights', W_0p15);
odf_0p3 = calcODF(ori_0p3,'weights', W_0p3);
figure;plotPDF(odf_0p15,h)
figure;plotPDF(odf_0p3,h)