MATLAB: Retrieve binary data back

encryption

I have a binary data as
00 10 11 01 10 11 11 01
I need to replace this data as if
00 = 0
01 = 1
10 or 11 = *
if i get a new data as below
0 * * 1 * * * 1
can you suggest any way to get back the binary data
00 10 11 01 10 11 11 01

Best Answer

In case you wanted to accept my answer, I'll repost my code in an actual answer. However, I would suggest you use Madhan's solution. That one ignores the last bit if the length is odd (which might not be what you want), while my code throws an error.
data='0010110110111101';
replace_with={'00','0';'01','1';'10','*';'11','*'};
key_list=replace_with(:,1);
val_list=replace_with(:,2);
%check for even numbers:
if rem(numel(data),2)~=0
error('bits are not paired')
end
%convert to 1 pair per cell
datacell=mat2cell(data,1,2*ones(numel(data)/2,1));
% %loop through the replacer elements
% for n=1:numel(key_list)
% datacell(ismember(datacell,key_list{n}))=val_list(n);
% end
inds=cellfun(@(x) find_indices(x,key_list),datacell);
L= inds~=0;
datacell(L)=val_list(inds(L));
%convert back to a char array
result=cell2mat(datacell);
clc,disp(result)
%local function:
function inds=find_indices(element,key_list)
[~,inds]=ismember(element,key_list);
end