message=[0 1 1 0 1 0 1];
data=zeros(1,2*length(message));
data(1:2:14)=message;
i=1:length(message);
j=1.99:length(message)+0.99;
time=[ ];
for k=1:7
time=[time i(k) j(k)];
end
signal=[ ];
for t=1:2:14
if (data (t)==0)
signal (t:t+1)=0;
else
signal (t:t+1)=1;
end
end
figure (1);
plot (time, signal,'linewidth',2);
title ('Line Coding1' );
xlabel('Time');
xlim([1 8]);
ylabel('Amplitude');
ylim([-2 2]);
grid on
this is the right matlab code for the qs above.