This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function saveFigure(fname,varargin) | |
% save figure as graphics file | |
% | |
% Description | |
% This function is supposed to produce cropped, publication ready image | |
% files from your plots. The format of the file is determined by the | |
% extension of the filename. | |
% | |
% Syntax | |
% saveFigure(fname) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% select profile | |
lineX = ginput(2) % select a line | |
[ebsd_lineX, dist ]= spatialProfile(ebsd,lineX); %extract orientations | |
%% average orientations perpendicular to profile and plot things along line | |
clear meanO | |
% average along line (put 0 if you want no averaging) | |
%////////////////////////////////////////////////////// | |
av_width = 8 %number of pixels to average perp to line (towards both sides | |
% use 0 to use only ebsd_lineX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [gkam, gid, kam] = gKAM(ebsd,varargin) | |
% calculate grain average misorientation angle from KAM | |
% input: | |
% ebsd (with grainID) | |
% | |
% options: | |
% threshold: angles to ignore (upper limit) in radian | |
% lowlim: angles to ignore: (lower limit) in radian | |
% order: 1st,2nd etc. neighbourhood around each point | |
% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% crystal shape demo | |
% needs @crystalShape avaiable in mtex 4.5.3 | |
% script plots a map and the user can select points where a little crystal shape | |
% will be dispalyed -crystal will be cc according to the map | |
mtexdata titanium | |
[grains,ebsd.grainId]=calcGrains(ebsd,'angle',5*degree); | |
% plot something | |
cs=ebsd('t').CS; | |
f=newMtexFigure; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function SF = BinghamSphericalFunction(r,Z,varargin) | |
% define a Bingham Distribution on a sphere | |
% | |
% Input | |
% r - @ rotation | |
% Z - 3-by-1 smoothing parameter with Z(1)>=Z(2)>=Z(3), Z3<0 | |
% or diagonal matrix with Z1, Z2 ,Z3 | |
% Z1=Z2 rotationally symmetric unimodal distribution | |
% Z1<<Z2 (partial girdle distribution | |
% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [ebsd, grains]=loadPhaseMap(varargin) | |
% Load a phase map and create "ebsd" which can be used with some | |
% of the avaiable tools for grain/grainboundary analysis | |
% | |
% Three cases are be distinguished. | |
% | |
% 1) Single phase,tightly packed no matrix ('single') | |
% input: boundary map - binary image ("white" boundaries, value should be 255)! | |
% output: ebsd with grains of distinct, nonsense orientation and notIndexed | |
% at the boundaries |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% import demo data | |
mtexdata forsterite | |
% prepare some data that might look interesting | |
[grains, ebsd.grainId, ebsd.mis2mean]=calcGrains(ebsd); | |
ebsd=ebsd(grains(grains.grainSize>100 & grains.phase==1)); %discard all small grains and non-forsterite grains before labeling | |
[grains, ebsd.grainId, ebsd.mis2mean]=calcGrains(ebsd,'unitcell'); | |
% plot grains and find an interesting one | |
om=ipfHSVKey(ebsd('f').CS,ebsd('f').CS); | |
om.maxAngle=10*degree; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [pfTindex, m, pfg_max] = pfIntensity(odf,h) | |
% calculate pfJ using S2Fun | |
% input: | |
% odf - odf | |
% h - Miller | |
% output: | |
% pfTindex - pole figure J index | |
% m - multiplicity (needs to be considered when comparing pfJ of different h) | |
% pfmax - max of pf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [totfreq, bc, azi]=calcTDF(g,varargin) | |
% calc circular axis/ trend distribution function of grain long axes | |
% OR grain boundary segments or from a list of angles for axial data (0:pi) | |
% | |
% Syntax: | |
% [freq,bc] = calcTDF(smoothgrains.boundary('indexed')) | |
% or | |
% [freq,bc] = calcTDF(smoothgrains('indexed')) | |
% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function h = ellipse(r,a,b,varargin) | |
% annotate an ellipse | |
% | |
% Input | |
% r - @rotation specifying the ellipse position | |
% a,b - long/short half axes of ellipse in radian | |
% | |
h = []; | |
rho=(0:1:360)*degree; |
OlderNewer