# How to convert a continuous figure to discrete?

3 visualizaciones (últimos 30 días)
Enez Furkan Cihan el 22 de Jul. de 2019
Comentada: Enez Furkan Cihan el 22 de Jul. de 2019
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.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

David K. el 22 de Jul. de 2019
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 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Enez Furkan Cihan el 22 de Jul. de 2019
I appreciate, David! It really helped out.

Iniciar sesión para comentar.

### Categorías

Más información sobre Annotations en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by