Reputation: 7319
The x-axis range seems to begin at the first data point and end at the last by default. I'd like to extend this a little bit in both directions so my graph looks zoomed out a bit. How do I set this? I don't see it in the stem documentation.
example code:
f = [0.0 0.45 0.55 1.0];
a = [1.0 1.0 0.0 0.0];
filter = firpm(10,f,a);
plot(f,a);
stem(filter);
and I want to change the x-axis from 0 to 20 (it currently defaults at 1 to 11).
Upvotes: 1
Views: 3437
Reputation: 112659
This is not done by stem
or any other plotting function. To control axis range you use either axis
:
axis(limits)
specifies the limits for the current axes. Specify the limits as vector of four, six, or eight elements. [...]
or xlim
:
xlim(limits)
specifies the x-axis limits for the current axes. Specify limits as a two-element vector of the form[xmin xmax]
, wherexmax
is greater thanxmin
. [...]
xl = xlim
returns a two-element vector containing the current limits. [...]
For example, to extend the current range of the x axis 1 unit to each side:
xlim(xlim + [-1 1])
(note that this uses the two types of calls described in the xlim
documentation excerpts above).
Or, in your specific example,
xlim([0 20])
Upvotes: 2