I have been asked to take a barcode symbol sequence, and replace each number substring with the actual number representation. In other words, a number '1' in the barcode sequence is represented by '...::'. Each number [0-9] is represented by a 5 character symbol. Each barcode is made up of 10 digits, so I want to create a number string that is equivalent to the symbolic barcode string.
ex.-
'...:::.:.....::::....:..::.:..:.:..:.:..:..:.::...' would be equivalent to 1910499980
What I am trying to accomplish is to capture each 5 character sequence, replace it with its numeric equivalent, then move on to the next 5 character sequence. The code I have so far is below, but it does not function correctly, it replaces some of the symbols, but not all. It also substitutes some of the numbers incorrectly. I forgot to mention that the first character of each line is to be omitted, so a portion of my code has already taken care of that.
Any help you can provide would be great,
Thanks, Dan
barcodes = {':...:::.:.....::::....:..::.:..:.:..:.:..:..:.::...';
':::...:..:...::...::.::.....:.:.:..:..::...:.:..:.:';
'::.:...:..:.::..::...:...:::.....::...::.::...:..:.';
'::...:.:..:::...:...::..:...:.:..::.:..:..:..::...:';
':::....::...:.:...:.:::...:.:..:.:..::...::...:.:..';
':.:..:..::...:.:...::::......:::...:.:..:.::..:...:';
'::.:..:..:....::..:.:..:.:.:..:..::..:.:.:..:.:..:.';
':.::.....:::...:.::.....::..::..:..:.:..:.:..:.:..:';
'::...::..:..::...::...::..:...:.:.:.:...:.:.:...::.';
'::..:...::...:.:::......:::..:...::..:..:..:.::.:..';
'::..:...:.:::...:...:...::.:..:.:..:.:..:.:..:.::..';
':.:..::..:.:..:...:.:.:..::.:..:.:..:.:..:..:.:.:..';
':..::...:.:..::.::....::....::..:..:..:.:.:.:...:.:';
':..::..::.....::::....:..:.:.:.:.:..:..:...::....::';
':.::...::...:.:.::....::....:.:::.....:.:..::.:...:';
'::..:..:..:..::...:.:..:.:.:..:..::.:.:...:..:...::';
':.:.:.:...:::...::...:...:..::..:..:..:.:.:..::..:.';
':...::..:.:..:.:.:..:.::....::.:..:.:..:.:..:.:..:.';
':..:.:..::.:..:.::....::..:...:.:..:..::...:.::...:';
':.:..::...::..:.::...:.:....::.:..:...:.:...:::..:.';
'::..:..:.:.::...::....:..:.:..:..::..:.:..:..::...:';
'::..:.::....:.:...:.:..::.:..:..:..:..::...:.:.:.:.';
':.:.:..::..::...::......:::..:..:..:.:.:..:.:..::..';
':..::.:...:..:.:::...:.:.....::..:.:...::..::...:.:';
':.:..:::....::..::......::.::...::...:.:..:..::..:.';
':..:.::...:.::..:.:...:.:..:..:..::...:.::.:....::.';
':.::...:.:.:..:.:.:..:...:.:..::.:....::...:.::...:';
':..::.::.....::.::.....::.:..:..:..::...:.:..::..:.';
':::.....:.:...::..::.:.:..::...::...::...::....:.:.';
':::...:..:..:.:..:..:::....:..:.:.:..:.:...::.:...:';
':::.....:.::.:..::.....::..:..:..::...:.::.:..:..:.';
'::..:.:.:..::...::.....:.:.::..::....::..::...:.:..';
':.:.:.::...::......::...::..::..:..:.:..:..:.:::...';
':.:.:...::.:...:::....::..:.:....::...:.:...::.:..:'};
pat1 = '...::';
pat2 = '..:.:';
pat3 = '..::.';
pat4 = '.:..:';
pat5 = '.:.:.';
pat6 = '.::..';
pat7 = ':...:';
pat8 = ':..:.';
pat9 = ':.:..';
pat0 = '::...';
num1 = '1';
num2 = '2';
num3 = '3';
num4 = '4';
num5 = '5';
num6 = '6';
num7 = '7';
num8 = '8';
num9 = '9';
num0 = '0';
patterns = [pat1;pat2;pat3;pat4;pat5;pat6;pat7;pat8;pat9;pat0];
numbers = [num1;num2;num3;num4;num5;num6;num7;num8;num9;num0];
eachString = [];
barcodeMinusFirst = [];
for i = 1:length(barcodes);
eachString = [eachString; cellstr(barcodes(i))];
end
barcodeStrings = char(eachString);
barcodeStrings = barcodeStrings(:,2:end);
barcodeStrings = cellstr(barcodeStrings);
patternCell = cellstr(patterns);
numberCell = cellstr(numbers);
for i = 1:length(barcodes)
newBarcodes = regexprep(barcodeStrings, patternCell, numberCell);
end