Discussion:
impz/stem/ploting
Tarmo Tapio
2018-11-12 13:15:27 UTC
Permalink
When I try to plot code1 I get error but using code2 plotting works but
start from 0 not -20. What is wrong my code1 (proakis). I have xubuntu
18.04 and Octave 4.2.2.

code1

b = [1]; a = [1, -1, 0.9];
n = [-20:120];
h = impz(b,a,n);
subplot(2,1,1); stem(n,h)
title('Impulse Response'); xlabel('n'); ylabel('h(n)')


error: stem: inconsistent sizes for X and Y
error: called from
    __stem__>check_stem_arg at line 276 column 11
    __stem__ at line 37 column 40
    stem at line 127 column 8
    example2_11 at line 4 column 17

code2
b = [1]; a = [1, -1, 0.9];
n = [120];
h = impz(b,a,n);
subplot(2,1,1); stem(h)
title('Impulse Response'); xlabel('n'); ylabel('h(n)')
Mike Miller
2018-11-12 17:24:31 UTC
Permalink
Post by Tarmo Tapio
When I try to plot code1 I get error but using code2 plotting works but
start from 0 not -20. What is wrong my code1 (proakis). I have xubuntu 18.04
and Octave 4.2.2.
The problem is that Octave's impz only allows the third argument N as a
scalar (number of samples), not a vector of time offsets as you are
trying
Post by Tarmo Tapio
n = [-20:120];
h = impz(b,a,n);
Try the following instead

n = 120;
[h, t] = impz (b, a, n);
stem (t, h);

If you were using the latest version of the signal package, you would
have seen a different error message

error: impz: N must be empty or a scalar
--
mike
Loading...