from
Luhn Algorithm Functions
by David Chandler
Luhn algoritm check and computation of missing digit.
|
| findluhndig(num)
|
function dig = findluhndig(num)
% dig = findluhndig(num). If num is a string of numbers, with a
% missing digit substituted with 'X', then dig will supply the missing
% digit according to the Luhn algorithm. This function is dependent on
% luhncheck.
x_index = strfind(num, 'X');
for i = 0:9
num(x_index) = num2str(i);
if luhncheck(num)
dig = num(x_index);
end
end
|
|
Contact us at files@mathworks.com