how to obtain the graph?

조회 수: 1 (최근 30일)
TEHVISIVASANKERI NARAYANAN
TEHVISIVASANKERI NARAYANAN 2021년 5월 20일
답변: TEHVISIVASANKERI NARAYANAN 2021년 5월 24일
i having problem to obtain a graph for the line coding. The graph that i should obtain is below:
;
But by using this code: i can't get the above graph
message=[0 1 1 0 1 0 1];
data=zeros(1,2*length(message));
data(1:2:14)=message;
i=1:7;
j=1.99:7.99;
time=[ ];
for k=1:7
time=[i(k) j()];
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

채택된 답변

TEHVISIVASANKERI NARAYANAN
TEHVISIVASANKERI NARAYANAN 2021년 5월 24일
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.

추가 답변 (4개)

Thukiller
Thukiller 2021년 5월 20일
편집: Thukiller 2021년 5월 20일
you can try this
message=[0 1 1 0 1 0 1 1];
figure (1);
stairs(message);
title ('Line Coding1' );
xlabel('Time');
xlim([1 8]);
ylabel('Amplitude');
ylim([-2 2]);
grid on
  댓글 수: 2
TEHVISIVASANKERI NARAYANAN
TEHVISIVASANKERI NARAYANAN 2021년 5월 20일
thanks for your suggestion. after i try your code i obtain the graph as below. but the grph still does not same as how i supposely get it. can you help with this.
TEHVISIVASANKERI NARAYANAN
TEHVISIVASANKERI NARAYANAN 2021년 5월 20일
i have tried adding extra 1 at the message but at the command window this message was displayed
Unable to perform assignment because the left and right sides have a different number of elements.
Error in Linecoding1 (line 3)
data(1:2:14)=message;

댓글을 달려면 로그인하십시오.


Girijashankar Sahoo
Girijashankar Sahoo 2021년 5월 20일
message=[0 1 1 0 1 0 1 ];
data=[message 0]
stairs(data);
title ('Line Coding1' );
xlabel('Time');
xlim([1,8]);
ylabel('Amplitude');
ylim([-2 2]);
grid on
  댓글 수: 1
TEHVISIVASANKERI NARAYANAN
TEHVISIVASANKERI NARAYANAN 2021년 5월 20일
since in the intial coding i given above has declare data itself in the coding so by adding extra data i could not get the figure that i should obtained

댓글을 달려면 로그인하십시오.


Girijashankar Sahoo
Girijashankar Sahoo 2021년 5월 20일
You have 7 bit, plot in time index 1-2, 2-3, 3-4,4-5,5-6,6-7,7-8 at time index 8 it will reach to next transition value. So we take 0 as default zero pad. It does not impact on line code but complete waveform.
you can try with any another example message=[0 1 1 0 0 1 0 1 0 1 1 0 1]
after zeropad data=[message 0]
  댓글 수: 2
TEHVISIVASANKERI NARAYANAN
TEHVISIVASANKERI NARAYANAN 2021년 5월 21일
can i have the matlab code for this graph.
Girijashankar Sahoo
Girijashankar Sahoo 2021년 5월 22일
if it helps accept my answer

댓글을 달려면 로그인하십시오.


Girijashankar Sahoo
Girijashankar Sahoo 2021년 5월 22일
%% Bro code is same just put your message bit @message get desire line code
message=[0 1 1 0 1 0 1 ];
data=[message 0]
stairs(data);
title ('Line Coding1' );
xlabel('Time');
xlim([1,8]);
ylabel('Amplitude');
ylim([-2 2]);
grid on

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by