Guess I'll post the full code here, just in case.
clear;clc;close all
%% Vector Setup
% This section inputs all of the vectors for the applied stress, the slip
% directions, and the slip plane normals vectors.
stress_vectors = unique(combinations([0 1 -1 1/2 -1/2],[0 1 -1 1/2 -1/2],[0 1 -1 1/2 -1/2]));
slip_directions = [ 1 1 0
-1 -1 0
1 0 1
-1 0 -1
0 1 1
0 -1 -1];
slip_planes = [ 1 1 1
-1 -1 -1];
%% Counting
% This section finds how many vectors of each type there are for later
% calculations.
[number_of_vectors,dimensions1] = size(stress_vectors);
[number_of_slip_directions,dimensions2] = size(slip_directions);
[number_of_slip_planes,dimensions3] = size(slip_planes);
%% Schmid Factor Calculation
% This section calculates Schmid's Factor for each direction of applied
% stress. Schmid's Factor is found by multiplying two quantities: the first
% quantity is the dot product of the applied stress vector and the plane
% normal vector divided by the product of the magnitudes of each vector,
% and the second quantity is the dot product of the applied stress and the
% slip direction vector divided by the product of each vector's magnitude
schmid_factor = zeros(number_of_vectors,number_of_slip_directions,number_of_slip_planes);
for n = 1:(number_of_vectors)
for o = 1:(number_of_slip_directions)
for p = 1:(number_of_slip_planes)
schmid_factor(n,o,p) = ( ...
dot( ...
stress_vectors(n,:), ...
slip_planes(p,:) ...
) ...
/ ...
sqrt( ...
dot(stress_vectors(n,:),stress_vectors(n,:)) ...
* ...
dot(slip_planes(p,:),slip_planes(p,:)) ...
) ...
)...
*...
( ...
dot( ...
stress_vectors(n,:), ...
slip_directions(o,:) ...
)...
/ ...
sqrt( ...
dot(stress_vectors(n,:),stress_vectors(n,:)) ...
*...
dot(slip_directions(o,:),slip_directions(o,:)) ...
) ...
);
end
end
end
%% Finding the number of non-zero slip systems per applied stress vector
% This section counts the number of Schimd's Factors per applied stress
% vector that don't equal zero, then appends that number to the original
% set of stress vectors for use in an fprintf function that outputs a
% statement listing the number of slip systems per applied stress vector.
non_zero_slip_systems = zeros(number_of_vectors,1);
for q=1:number_of_vectors
non_zero_slip_systems(q,1) = numel(find(schmid_factor(q,:,:) ~= 0));
end
applied_stress_and_system_count_matrix = sortrows([stress_vectors,non_zero_slip_systems],4);
formatSpec = 'Applied stress vector [%1.0f %1.0f %1.0f] has %1g slip systems\n';
%% ANSWERS
fprintf(formatSpec,(applied_stress_and_system_count_matrix'))