Annie
Annie

Reputation: 1

Starting the stem-plot from zero instead of one on the x-axis

I am trying to plot a function using the filter feature in MATLAB. I would like my graph to start at zero but it is starting at one for some reason. Here is the code I have:

x2 = zeros(1,20);
x2(1) = 1;

A = [1 -0.9];
B = [1 0];

y3 = filter(B,A,x2);

figure(3);

stem(y3);

I have also added a screenshot of my graph.

How can I get the first impulse to start at zero instead of one?

Upvotes: 0

Views: 940

Answers (1)

Sardar Usama
Sardar Usama

Reputation: 19689

Specify both the x and y axis values.

stem(0:numel(y3)-1, y3);

When x-axis values are not specified, these are automatically taken as integers from 1 to number of y terms. Read the documentation for further details and examples.

Upvotes: 2

Related Questions