How to convert a continuous figure to discrete?

5 ビュー (過去 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)
  1 件のコメント
Enez Furkan Cihan
Enez Furkan Cihan 2019 年 7 月 22 日
I appreciate, David! It really helped out.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by