필터 지우기
필터 지우기

Plot of binary data

조회 수: 36 (최근 30일)
Gova ReDDy
Gova ReDDy 2014년 6월 2일
댓글: Henric Rydén 2014년 6월 2일
Hello,
I want to plot a set of binary values such that each binary value will be shown for 50 seconds. I tried like this but was unable to get the pulse signal of binary values(0 and 1). binary =[1 1 0 1 0 0 1 0];assume this is my binary data
for l=1:1:length(binary)
for t=i:1:i+50
plot(t,binary(l),'-r');
ylim([-2 2]);
end
i=i+1;
end
can someone suggest in plotting this binary data(as I want to plot the data in real time).
Thank you.
  댓글 수: 1
Henric Rydén
Henric Rydén 2014년 6월 2일
i is not defined

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

채택된 답변

Henric Rydén
Henric Rydén 2014년 6월 2일
If you want to show each value in binary for 50 seconds
binary =[1 1 0 1 0 0 1 0];
figure;
for idx = 1 : length(binary)
stem(0,binary(idx));
xlim([-1 1]);
ylim([0 1.5]);
title(['Binary (' num2str(idx) ')']);
drawnow;
pause(50);
end
  댓글 수: 4
Gova ReDDy
Gova ReDDy 2014년 6월 2일
Thanks.Can I know how to show the binary plot as square pulse as shown in the below figure instead of stem representation.
Henric Rydén
Henric Rydén 2014년 6월 2일
Sure! There are many ways to do this, but replace stem with bar and you're halfway there:
bar(1:8,binary(end-7:end),'BarWidth',1);
If you want something more similar to what you've drawn, you should use line . But you should center the pulses over the values to avoid confusion.
stem is a more correct way to represent the data, since values are not defined between integers.

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

추가 답변 (0개)

카테고리

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