How can i plot the sum of two discrete signal?
问题 I have a discrete signal x = [ 1 2 3 4 5 6 ] with n = [ -2 -1 0 1 2 3 ] How can i plot y[n] = x[n-1] + x[n-2] + x[n] ? Thanks. 回答1: You can do the following: y = x(1:end-2) + x(2:end-1) + x(3:end); plot(n(3:end), y) 回答2: This looks like a filter... You should consider using the filter function to calculate y : x = [...whatever...]; % Filter coefficients from your difference equation. b = [1 1 1]; a = 1; y = filter(b, a, x); plot(n, y); This will handle initial conditions more appropriately