How to plot a piecewise in MATLAB?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Siddharth Garg
el 8 de Sept. de 2019
Editada: Siddharth Garg
el 8 de Sept. de 2019
I have this piecewise function and I have to plot this discrete signal using the stem function. This is what I wrote:

And this is the error I am getting:

What is it that I am doing wrong?
Respuesta aceptada
Star Strider
el 8 de Sept. de 2019
I prefer the anonymous function approach:
x = @(n) n.*((0<=n) & (n<=8)) + 1*((-4<=n) & (n<=-1));
n = -10:12;
figure
stem(n, x(n))
grid
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Line Plots 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!