I understand that you want to write a function for finding the multiplicity factor given a 1x3 array of the h,k,l values for the planes. As per the table you have provided, there are a lot of different cases. This can be accomplished using a switch case instead of if statements. You can refer to the below code for a blueprint on how to implement it.
function multiplicity = getMultiplicitySwitch(hkl, crystalSystem)
% Determines the multiplicity based on the crystal system using switch case
switch crystalSystem
case 'cubic'
multiplicity = getCubicMultiplicity(hkl);
% Add other cases for different crystal systems
otherwise
error('Unknown crystal system');
end
end
function multiplicity = getCubicMultiplicity(hkl)
% Example function for cubic system multiplicity determination
h = hkl(1);
k = hkl(2);
l = hkl(3);
% Implement the actual rules for your system
end
% Example usage
hkl = [1, 0, 0];
crystalSystem = 'cubic';
multiplicity = getMultiplicitySwitch(hkl, crystalSystem);
fprintf('Multiplicity for [%d %d %d] in %s system: %d\n', hkl, crystalSystem, multiplicity);
Also there is a simpler formula to calculate the multiplicity in case of cubic systems. It is as follows:
Here m is the multiplicity, N is the number of zeros present in the [h,k,l] vector and n is the number of repeated values including 0.
This formula has origins in group theory. You can find similar formulae for other cases to simplify your calculations.
You can find details about the above formula on the following link: https://physics.stackexchange.com/questions/523836/equation-for-the-multiplicity-of-a-set-of-planes
I hope this helps.