# How can I plot this signal with DiscretePlot?

How can I plot this signal with DiscretePlot?

This mean:

x[-2] = 3, x[-1] = -1, x[0] = 0, etc


This doesn't produce the desired output.

DiscretePlot[{3, -1, 0, -2, 1, -2, -4, 0,
1}, {n, {-2, -1, 0, 1, 2, 3, 4, 5, 6}}]

• ListPlot[ Transpose[{{-2, -1, 0, 1, 2, 3, 4, 5, 6}, {3, -1, 0, -2, 1, -2, -4, 0, 1}}], Filling -> Axis] Commented Oct 31, 2022 at 1:31

DiscretePlot needs expression not list on the left side

Notice it says expression. i.e. some expression as function of n it it, which you do not have. You have list of numbers. If you can find a formula that represent your list of numbers, as function of n, then you can use DiscretePlot

You can use list plot with Filling->Axis. To get the origin to start where you wanted, one way is to build the {x,y} data yourself so it comes out automatically correct without needing to adjust Axes origin.

y = {3, -1, 0, -2, 1, -2, -4, 0, 1}
x = Range[-2, Length[y] - 3]
data = Transpose[{x, y}]
ListPlot[data, Mesh -> All, Filling -> Axis, PlotStyle -> Red]


If you define your function as:

x[-2] = 3; x[-1] = -1; x[0] = 0; x[1] = -2; x[2] = 1; x[3] = -2; x[4] = -4; x[5] = 0;x[6] = 1;


You may then using DiscretePlot, writing:

DiscretePlot[x[i], {i, -2, 6}]


If you want to use DiscretePlot, you can make the function f have the values on those inputs:

Clear@f
(f[#1] = #2) & @@@ Transpose[{{-2, -1, 0, 1, 2, 3, 4, 5, 6}, {3, -1, 0, -2, 1, -2, -4, 0, 1}}];
DiscretePlot[f[x], {x, -2, 6}]