[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: digital differentiator using remez
From: |
Paul Kienzle |
Subject: |
Re: digital differentiator using remez |
Date: |
Thu, 8 Feb 2007 22:41:35 -0500 |
On Feb 8, 2007, at 2:17 AM, Ron Crummett wrote:
Hi -
I am trying to design a 4th order wideband differentiator using the
remez function.
See below for a patch.
I type in
b = remez(4, [0 0.75], [0 0.75*pi], [], 'differentiator');
And I get this response:
error: invalid conversion from matrix to real vector
error: remez: need one weight for each band [=length(band)/2]
error: evaluating assignment expression near line 22, column 3
I think this error is because 'differentiator' returns true
for is_matrix_value(), but doesn't want to be converted to
a vector for some reason. I get around this in the new code
by checking first if it is a string.
My only guess is that I need something in the weighting entry, so I
change it to
b = remez(4, [0 0.75], [0 0.75*pi], 1, 'differentiator');
Which gives me the message:
error: remez: griddensity is too low; must be greater than 16
error: evaluating assignment expression near line 22, column 3
I was trying to be clever: scalar => grid density,
vector => weights; unfortunately this breaks when
you only have one band and the vector is of length 1.
I couldn't stomach the firpm solution to this problem:
put grid density in a cell array, and instead force
you to type ...,'bandpass',griddensity) if you want
to set the grid density.
A third attempt:
b = remez(4, [0 0.75], [0 0.75*pi], 1, 'differentiator', 64);
error: remez: incorrect argument list
error: evaluating assignment expression near line 22, column 3
Same problem as above.
At this point I am out of ideas of what I need to change. Has anyone
had any success with this? I am running 2.9.6 on Kubuntu breezy.
Thanks.
I'm posting the following patch to octave-forge cvs:
Index: remez.cc
===================================================================
RCS file: /cvsroot/octave/octave-forge/main/signal/src/remez.cc,v
retrieving revision 1.1
diff -c -p -r1.1 remez.cc
*** remez.cc 20 Aug 2006 13:58:25 -0000 1.1
--- remez.cc 9 Feb 2007 03:33:35 -0000
*************** Frequency is in the range (0, 1), with 1
*** 817,823 ****
OCTAVE_LOCAL_BUFFER (double, weight, numbands);
for (i=0; i < numbands; i++) weight[i] = 1.0;
if (nargin > 3) {
! if (args(3).is_real_matrix()) {
ColumnVector o_weight(args(3).vector_value());
if (o_weight.length() != numbands) {
error("remez: need one weight for each band [=length(band)/2]");
--- 817,825 ----
OCTAVE_LOCAL_BUFFER (double, weight, numbands);
for (i=0; i < numbands; i++) weight[i] = 1.0;
if (nargin > 3) {
! if (args(3).is_string())
! stype = args(3).string_value();
! else if (args(3).is_real_matrix() || args(3).is_real_scalar()) {
ColumnVector o_weight(args(3).vector_value());
if (o_weight.length() != numbands) {
error("remez: need one weight for each band [=length(band)/2]");
*************** Frequency is in the range (0, 1), with 1
*** 825,834 ****
}
for (i=0; i < numbands; i++) weight[i] = o_weight(i);
}
- else if (args(3).is_string())
- stype = args(3).string_value();
- else if (args(3).is_real_scalar())
- density = NINT(args(3).double_value());
else {
error("remez: incorrect argument list");
return retval;
--- 827,832 ----
*************** Frequency is in the range (0, 1), with 1
*** 837,843 ****
if (nargin > 4) {
if (args(4).is_string() && !args(3).is_string())
stype = args(4).string_value();
! else if (args(4).is_real_scalar() && !args(3).is_real_scalar())
density = NINT(args(4).double_value());
else {
error("remez: incorrect argument list");
--- 835,841 ----
if (nargin > 4) {
if (args(4).is_string() && !args(3).is_string())
stype = args(4).string_value();
! else if (args(4).is_real_scalar())
density = NINT(args(4).double_value());
else {
error("remez: incorrect argument list");
*************** Frequency is in the range (0, 1), with 1
*** 845,854 ****
}
}
if (nargin > 5) {
! if (args(5).is_real_scalar()
! && !args(4).is_real_scalar()
! && !args(3).is_real_scalar())
! density = NINT(args(4).double_value());
else {
error("remez: incorrect argument list");
return retval;
--- 843,851 ----
}
}
if (nargin > 5) {
! if (args(5).is_real_scalar()
! && !args(4).is_real_scalar())
! density = NINT(args(5).double_value());
else {
error("remez: incorrect argument list");
return retval;