필터 지우기
필터 지우기

How to convert a continuous figure to discrete?

조회 수: 10 (최근 30일)
Enez Furkan Cihan
Enez Furkan Cihan 2019년 7월 22일
댓글: Enez Furkan Cihan 2019년 7월 22일
The figure is exactly looks like below I provided. It's actually kind of a bit vector [1 1 1 1 1 1 1 0 1 1] so I expect from it that goes to 0 directly at 8, Not by linear way; by another meaning I want it looks like a square wave there.
I tried to use 'c2d' but couldn't get what I want.
Thanks in advance
fur.png

채택된 답변

David K.
David K. 2019년 7월 22일
A couple different ways to do this. When plotting discrete values it is often preferred to use stem instead of plot. It does not connect the lines so probably not what you want. What you likely want is the answer from this question :
What they do is they add more samples so that the plot looks square.
They do it in a way that will work for any bit series :
x = [1 1 1 1 1 1 1 0 1 1];
x = repmat(x',1,100)';
x = x(:)';
t = linspace(0,10,numel(x));
plot(t,x)
Where the 100 is somewhat arbitrarily chosen as a higher order.
This is currently set up so that the plot becomes 0 and 7 and 1 at 8. Since I'm not sure that is exactly how you want it. When plotting you could probably do
plot(t+.5,x)

추가 답변 (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