1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| %Data
Data = [1 0 1 0 0 1 1 1 0 0 1];
Data = [Data;Data];
% Clock
Clock = repmat([1;0],numel(Data)/2,1);
% Manchester code
MC = (Data(:)&Clock(:)) | (~Data(:)&~Clock(:));
% Data from Manchester code
DM = xor(Clock(:),~MC (:));
% Period
T = 5;
t = 0:T/4:T/4*numel(MC )-1;
figure
subplot(411)
stairs(t(:),Clock(:),'r-')
title('Clock')
set(gca,'ylim',[-.5 1.5],'xlim',[0 max(t)], ...
'xtick',t(1:2:end),'xticklabel','',...
'xgrid','on')
subplot(412)
stairs(t(:),Data(:),'r-')
title('Data')
set(gca,'ylim',[-.5 1.5],'xlim',[0 max(t)], ...
'xtick',t(1:2:end),'xticklabel','',...
'xgrid','on')
subplot(413)
stairs(t(:),MC (:),'r-')
title('Manchester code')
set(gca,'ylim',[-.5 1.5],'xlim',[0 max(t)], ...
'xtick',t(1:2:end),'xticklabel','',...
'xgrid','on')
subplot(414)
stairs(t(:),DM(:),'r-')
title('Data from Manchester code')
set(gca,'ylim',[-.5 1.5],'xlim',[0 max(t)], ...
'xtick',t(1:2:end),'xticklabel','',...
'xgrid','on') |
Partager