-1

我必须制作过滤器,这是我的代码:

octave:1> x=randn(500);
octave:2> b=fir1(50,0.2,'stop',boxcar(51));
error: `boxcar' undefined near line 2 column 22
error: evaluating argument list element number 4

这里有什么问题?

低通滤波器在 Octave 中是“低”还是“停止”?

@edit 新错误:

octave:2> b=fir1(50,0.2,'stop');
error: `fir1' undefined near line 2 column 3

有没有可能我什么都没有?

4

2 回答 2

1

您可能需要加载包(请参阅Octave 常见问题解答)。运行pkg list以确认包是否已安装以及是否已加载。它将显示所有已安装软件包的表格,在已加载的软件包前面带有星号。您将无法使用未加载的包。请参阅以下 Octave 会话。

octave> partcnt (7)   # does not work because function is not in search path
error: `partcnt' undefined near line 9 column 1
octave> pkg list      # show list of packages
Package Name   | Version | Installation directory
---------------+---------+-----------------------
      control  |   2.4.1 | /home/carandraug/octave/control-2.4.1
      general  |   1.3.2 | /home/carandraug/octave/general-1.3.2
generate_html  |   0.1.5 | /home/carandraug/octave/generate_html-0.1.5
        image  |   2.1.0 | /home/carandraug/octave/image-2.1.0
miscellaneous  |   1.2.0 | /home/carandraug/octave/miscellaneous-1.2.0
        optim  |   1.2.2 | /home/carandraug/octave/optim-1.2.2
       signal  |   1.2.0 | /home/carandraug/octave/signal-1.2.0
      specfun  |   1.1.0 | /home/carandraug/octave/specfun-1.1.0
       struct  |  1.0.10 | /home/carandraug/octave/struct-1.0.10

octave> pkg load miscellaneous  # load package
octave> partcnt (7)             # it works now
ans =  15
octave> pkg list                # confirm that package is loaded (* in front of the name)
Package Name   | Version | Installation directory
---------------+---------+-----------------------
      control  |   2.4.1 | /home/carandraug/octave/control-2.4.1
      general *|   1.3.2 | /home/carandraug/octave/general-1.3.2
generate_html  |   0.1.5 | /home/carandraug/octave/generate_html-0.1.5
        image  |   2.1.0 | /home/carandraug/octave/image-2.1.0
miscellaneous *|   1.2.0 | /home/carandraug/octave/miscellaneous-1.2.0
        optim  |   1.2.2 | /home/carandraug/octave/optim-1.2.2
       signal  |   1.2.0 | /home/carandraug/octave/signal-1.2.0
      specfun  |   1.1.0 | /home/carandraug/octave/specfun-1.1.0
       struct  |  1.0.10 | /home/carandraug/octave/struct-1.0.10

octave> pkg unload all    # unload the package
octave> partcnt (7)       # no longer works because it was removed from path
error: `partcnt' undefined near line 15 column 1
octave> pkg list
Package Name   | Version | Installation directory
---------------+---------+-----------------------
      control  |   2.4.1 | /home/carandraug/octave/control-2.4.1
      general  |   1.3.2 | /home/carandraug/octave/general-1.3.2
generate_html  |   0.1.5 | /home/carandraug/octave/generate_html-0.1.5
        image  |   2.1.0 | /home/carandraug/octave/image-2.1.0
miscellaneous  |   1.2.0 | /home/carandraug/octave/miscellaneous-1.2.0
        optim  |   1.2.2 | /home/carandraug/octave/optim-1.2.2
       signal  |   1.2.0 | /home/carandraug/octave/signal-1.2.0
      specfun  |   1.1.0 | /home/carandraug/octave/specfun-1.1.0
       struct  |  1.0.10 | /home/carandraug/octave/struct-1.0.10

一般包之所以会在你加载的时候自动加载miscellaneous,是因为generalmiscellaneous.

于 2013-01-10T17:25:24.267 回答
0

手册页

usage: b = fir1(n, w [, type] [, window] [, noscale])

你可能想要例如:

b=fir1(50, [0.1 0.2], 'stop');
于 2013-01-10T15:24:22.613 回答