How to plot a piecewise in MATLAB?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Siddharth Garg
am 8 Sep. 2019
Bearbeitet: Siddharth Garg
am 8 Sep. 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?
Akzeptierte Antwort
Star Strider
am 8 Sep. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!