How to Compute Area Fractions of Variants (child phase) for a Single Grain (parent phase) #69
-
Hello Frank, job.grains("781").calcVariants # 781 was one of the grainIds Error in indexing (line 83) So, could you please help me figure out how I can estimate area fractions of variants for a specific single parent grain? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @Rhalder322, I've used the grainId from ORTools_example02 and snippets from the plotStack function to help answer your query: %% Define the parent grain
pGrainId = 110;
pGrain = job.parentGrains(job.parentGrains.id == pGrainId);
pEBSD = job.ebsd(pGrain);
pEBSD = pEBSD(job.csParent);
%% Define the child grain(s)
clusterGrains = job.grainsPrior(job.mergeId == pGrainId);
cGrains = clusterGrains(job.csChild);
cEBSD = job.ebsdPrior(job.ebsdPrior.id2ind(pEBSD.id));
cEBSD = cEBSD(job.csChild);
% Define a list of unique variants
uniqueVariantIds = 1:max(cGrains.variantId);
% Create a logical matrix indicating where each variant id appears in the
% variable 'cGrains.variantId'
logicalMatrix = bsxfun(@eq, cGrains.variantId(:), uniqueVariantIds(:)');
% Calculate grain area fractions of each variant using the logical matrix
areaFractions = sum(logicalMatrix .* cGrains.area(:), 1) / sum(cGrains.area); **Lastly, and importantly, if an explanation from the maintainers resolves your issue, please press the "Mark as answer" button on the appropriate response. Your assistance in this regard enables us to close discussions as complete. ** Hope this helps. Warm regards, |
Beta Was this translation helpful? Give feedback.
Hi @Rhalder322,
I believe you're asking 3 follow-up questions, not 1. :)
From your questions, it appears you have not watched the tutorial videos or gone through any of the example scripts to help you find the answers you are looking for.
So, as a first step, I'm advising you to please watch all the tutorial videos.
While doing that, please click on the functions within the example scripts to see how they are coded.
This will help you understand ORTools and more importantly, it will teach you how to use snippets of code to calculate or plot anything specific you have in mind.
Of course, if a function does not work as intended or if you need some additional functionality that is not part o…