clear all
close all
%% Import Script for EBSD Data
%
% This script was automatically created by the import wizard. You should
% run the whoole script or parts of it in order to import your data. There
% is no problem in making any changes to this script.
%% Specify Crystal and Specimen Symmetries
% crystal symmetry
CS = {...
'notIndexed',...
crystalSymmetry('mmm', [4.762 10.225 5.994], 'mineral', 'Forsterite', 'color', 'light blue'),...
crystalSymmetry('m-3m', [8.358 8.358 8.358], 'mineral', 'Chromite', 'color', 'light green')};
% plotting convention
setMTEXpref('xAxisDirection','east');
setMTEXpref('zAxisDirection','intoPlane');
%% Specify File Names
% path to files
pname = 'C:\Users\penny\Documents\!!!!!!PHD\Matlab\EBSD';
% which files to be imported
fname = [pname '\Kil_2_L2_284.ctf'];
a=3
%% Import the5Data
% create an EBSD variable containing the data
ebsd = loadEBSD(fname,CS,'interface','ctf',...
'convertEuler2SpatialReferenceFrame');
ebsd01 = ebsd('Forsterite');
b=3.8% maha parameter -3.8 best so far
[grains, ebsd01.grainId]= calcGrains(ebsd01,'FMC',b)
grains=smooth(grains)
gB = grains.boundary
plot(grains,grains.meanOrientation)
% select grain using the a curser on the phase map
disp(' ')
disp('Select grain with cursor and one mouse click')
disp(' ')
[x, y]=ginput(1);
% identify selected grains in the subset grainsForsterite
selectedgrain1 = findByLocation(grains,[x y])
oM = ipdfHSVOrientationMapping(ebsd01);
oM.inversePoleFigureDirection = orientation(grains(selectedgrain1).meanOrientation) * oM.whiteCenter;
%%
figure
oM.maxAngle = a*degree;
plot(ebsd01,oM.orientation2color(ebsd01.orientations))
hold on
plot(gB)
disp(' ')
disp('Select grain with cursor and one mouse click')
disp(' ')
[x2, y2, button]=ginput(1);
selectedgrain2 = findByLocation(grains,[x2 y2])
disp(' ')
disp('Select grain with cursor and one mouse click')
disp(' ')
[x3, y3]=ginput(1);
selectedgrain3 = findByLocation(grains,[x3 y3])
% define the cryastallographic direction d of the selected grain symmetry
d100 = Miller({1,0,0},grains(selectedgrain1).CS)
d010 = Miller({0,1,0},grains(selectedgrain1).CS)
d001 = Miller({0,0,1},grains(selectedgrain1).CS)
% define the orientation of the selected grains in Euler angles ori1 and
% ori2
ori2 = orientation(grains(selectedgrain2).meanOrientation)
ori3 = orientation(grains(selectedgrain3).meanOrientation)
% define the specific crystallographic direction of the specific selected
% grains
grainMiller2_100 = ori2 * d100
grainMiller3_100 = ori3 * d100
grainMiller2_010 = ori2 * d010
grainMiller3_010 = ori3 * d010
grainMiller2_001 = ori2 * d001
grainMiller3_001 = ori3 * d001
% calculates the angle between the two selected crystallographic directions
% of the two selected grains
angle_100 = angle(grainMiller2_100,grainMiller3_100) / degree
angle_010 = angle(grainMiller2_010,grainMiller3_010) / degree
angle_001 = angle(grainMiller2_001,grainMiller3_001) / degree
testangle = angle(grains(selectedgrain2).meanOrientation,grains(selectedgrain3).meanOrientation)/ degree
mori=inv(ori2).*ori3;
axis_crystal = mori.axis.project2FundamentalRegion('antipodal')
angle_146b=mori.angle('antipodal')/degree
antipodalOutput_146b =[angle_100, angle_010, angle_001, testangle]
antipodal_axis_Crystal_146b=[axis_crystal]
antipodal_angle_146b=[angle_146b]