# patch #10352: [octave forge] (signal) adding islinphase.m

 Submitter: Leonardo Submitted: Thu 25 May 2023 05:26:54 PM UTC Category: Forge : new function Priority: 5 - Normal Status: Need Info Privacy: Public Assigned to: None Open/Closed: Open
* Mandatory Fields

Add a New Comment Rich Markup

## Discussion

Sun 16 Jul 2023 12:01:01 PM UTC, comment #7:

Afaict, `islinphase` is part of the Signal Processing Toolbox of the MathWorks. The closest match for Octave would probably be the "signal" package.

Adding its maintainer to the CC-list of this report.

Markus Mützel <mmuetzel>
Thu 29 Jun 2023 12:36:15 PM UTC, comment #6:

It looks like grpdelay in octave accepts different arguments than the matlab version

John Donoghue <lostbard>
Wed 28 Jun 2023 05:13:38 PM UTC, comment #5:

Once again,

For the filter defined by b = [1 -1]; a = [1 -2]; the angle will be:

arg((1 - e^(-j ω))/(1 - 2 e^(-j ω)))

and the group delay will be:

d/dω(arg((1 - e^(-j ω))/(1 - 2 e^(-j ω)))) = (π j e^(j ω) δ((-1 + e^(j ω))/(-2 + e^(j ω))))/(e^(j ω) - 2)^2

and we may conclude that there is a discontinuity at ω = 0

reference:
https://www.wolframalpha.com/input?i=angle+%28+%281+-+e%5E%28-j%CF%89%29%29+%2F+%281+-+2e%5E%28-j%CF%89%29%29+%29

Leonardo <leolca>
Wed 28 Jun 2023 05:06:15 PM UTC, comment #4:

I guess the problem with this filter is that at ω = 0 we have undefined or indeterminate angle.

H(0) = (1 - e^(-j 0)) / (1 - 2e^(-j 0)) = 0 / (-1)

arg(0) = ?

In another approach, the numerator might be expressed by:
B(ω) = e^(-jω/2)(e^(jω/2) - e^(-jω/2)) = e^(-jω/2)(2j sin(ω/2))
arg(B(ω)) = -ω/2 + angle(2j sin(ω/2))

and the denominator by:
A(ω) = e^(-jω/2)(3jsin(ω/2) - cos(ω/2))
ang(A(ω)) = -ω/2 + arctan((3sin(ω/2)) / (-cos(ω/2)))

angle(H(ω)) = angle(2j sin(ω/2)) - arctan((3sin(ω/2)) / (-cos(ω/2)))

for ω > 0
angle(H(ω)) = π/2 - arctan((3sin(ω/2)) / (-cos(ω/2)))

for ω = 0 it is undefined.

That is causing the warning.

Here is the compared result of grpdelay in GNU Octave and Matlab for that particular filter:

GNU Octave
octave:1> pkg load signal
octave:2> b = [1 -1]; a = [1 -2];
octave:3> [gd, w] = grpdelay (b, a);
octave:4> [gd(1:10)'; w(1:10)']
ans =

-1.0000  -1.4999  -1.4995  -1.4990  -1.4982  -1.4972  -1.4959  -1.4945  -1.4928  -1.4909
0   0.0061   0.0123   0.0184   0.0245   0.0307   0.0368   0.0430   0.0491   0.0552

MATLAB

>> b = [1 -1]; a = [1 -2];
>> [gd, w] = grpdelay (b, a);
>> [gd(1:10)'; w(1:10)']

ans =

-1.5000   -1.4999   -1.4995   -1.4990   -1.4982   -1.4972   -1.4959   -1.4945   -1.4928   -1.4909
0    0.0061    0.0123    0.0184    0.0245    0.0307    0.0368    0.0430    0.0491    0.0552

Maybe we should point this to Paul Kienzle and Julius O. Smith III who have created the grpdelay.m function in GNU Octave.

To avoid this warning in the tests, we could just remove this one.

Leonardo <leolca>
Wed 28 Jun 2023 01:32:02 PM UTC, comment #3:

I diffed the attached grpdelay to mine and its the same, I also verified islinphase is the same as the attached file.

Removing the ';' on the polebins  = find (abs (den) < minmag) line in grpdelay and running I see:

> b = [1 -1]; a = [1 -2];

f = islinphase (b, a, 1E-1);
polebins = 1
warning: grpdelay: setting group delay to 0 at singularity
warning: called from
grpdelay at line 191 column 5
islinphase at line 94 column 9

John Donoghue <lostbard>
Wed 28 Jun 2023 12:55:06 PM UTC, comment #2:

I had no warning here.

'grpdelay' is a function from the file /usr/share/octave/packages/signal-1.4.3/grpdelay.m

The function grpdelay.m used follows attached.

(file #54891)

Leonardo <leolca>
Tue 27 Jun 2023 03:12:02 PM UTC, comment #1:

Some of the tests give warnings:

b = [1 -1]; a = [1 -2];
f = islinphase (b, a, 1E-1);
warning: grpdelay: setting group delay to 0 at singularity
warning: called from
grpdelay at line 191 column 5
islinphase at line 96 column 10

John Donoghue <lostbard>
Thu 25 May 2023 05:26:54 PM UTC, original submission:

Implementation of the function islinphase.

Leonardo <leolca>

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

Attached Files
file #54891:  grpdelay.m added by leolca (12KiB - text/x-objcsrc)
file #54782:  islinphase.patch added by leolca (5KiB - text/x-patch)
file #54783:  islinphase.m added by leolca (5KiB - text/x-objcsrc)

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

## Mail Notification Carbon-Copy List

Carbon-Copy List
• -email is unavailable- added by mmuetzel (Posted a comment)
• -email is unavailable- added by mmuetzel
• -email is unavailable- added by lostbard (Posted a comment)
• -email is unavailable- added by leolca (Submitted the item)
•

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

## History

Follow 7 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2023-07-16 mmuetzel CategoryCore : new function Forge : new function
Summaryadding islinphase.m [octave forge] (signal) adding islinphase.m