from
Builds reconciliation spreadsheet
by Aman Siddiqi
Combines two spreadsheets with different row headers using two row header matching techniques.
|
| answer=wordcomp(word1,word2)
|
function answer=wordcomp(word1,word2)
% Enter words as strings word2num('word','word')
% returns the lower word is 'a' when comparing 'a' & 'b'
% normalizes words to same length
if length(word1)>length(word2);
smaller=length(word2);
letters=length(word1);
word2(1,smaller+1:letters)=0;
else
smaller=length(word1);
letters=length(word2);
word1(1,smaller+1:letters)=0;
end;
% compares words letter by letter
indx=1;
while indx<letters+1
if word1(indx)<word2(indx)
answer=word1;
indx=letters+1; % stops comparison
elseif word1(indx)==word2(indx)
indx=indx+1;
answer=word1; % this is here in case the two words are the same
else
answer=word2;
indx=letters+1; % stops comparison
end
end
|
|
Contact us at files@mathworks.com