Plotting discrete piecewise function

15 Ansichten (letzte 30 Tage)
Gaurav Rudravaram
Gaurav Rudravaram am 1 Feb. 2021
Beantwortet: Walter Roberson am 1 Feb. 2021
Need to plot a discrete piecewise function.But the problem is between 6 and 9 the value should be (2n+1).Can somebody please help me out
x = @(n) 3*((0<=n) & (n<=5)) + 2*n.*((6<=n) & (n<=9)) + 0*((n<0) & (n>9));
n = -12:12;
figure
stem(n, x(n))
grid

Antworten (1)

Walter Roberson
Walter Roberson am 1 Feb. 2021
x = @(n) 3*((0<=n) & (n<=5)) + (2*n+1).*((6<=n) & (n<=9)) + 0*((n<0) | (n>9));
n = -12:12;
figure
stem(n, x(n))
grid

Kategorien

Mehr zu Surfaces, Volumes, and Polygons 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!

Translated by