bugGNU Octave - Bugs: bug #46440, [octave forge] (signal) missing...

 
 

bug #46440: [octave forge] (signal) missing function lp2lp

Submitted by:  Nicholas Jankowski <nrjank>
Submitted on:  Fri 13 Nov 2015 09:34:58 PM UTC  
 
Category:  Octave Forge Package Severity:  1 - Wish
Priority:  1 - Later Item Group:  Feature Request
Status:  Postponed Assigned to:  None
Originator Name:  Daniel Texidor Dantas Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Thu 15 Apr 2021 12:26:28 PM UTC, comment #10: 

Here is tftrans.  It does lowpass to LP/HP/BP/BS transformations directly in coefficient space.

(file #51274)

Tony Richardson <amrichardson>
Thu 15 Apr 2021 12:24:30 PM UTC, comment #9: 

I wrote four new LP to LP/HP/BP/BS functions that work directly with the transfer function coefficients.  I call these lp3lp, lp3hp, lp3bp and lp3bs.  The lp2* functions do the transformations in state-space and produce results similar to the MATLAB functions of the same name.

If the lowpass prototype filter is described by its coefficients, the lp3* functions appear to produce more accurate results than the lp2* functions.  The lp3* functions rely on a new function called tftrans to do the coefficient transformations.  It is similar to sftrans and sstrans which do transformations in pole-zero and state-space domains.

All of the lp3* functions include demo code to illustrate their usage.

I will include the lp3* functions in this comment and the tftrans function in the next one.

Here is a simple script to show the differences between lp2bp and lp3bp when doing a lowpass-to-bandpass transformation on a second order lowpass Butterworth filter.  Theoretically this should produce a fourth order bandpass filter with all (four) zeros at the origin.  The lp2bp function creates zeros that are slightly displaced from the origin.  Increase the value of n to see the differences for higher order filters.

% Nth order Butterworth Lowpass
n = 2;
Wo = 1000; Bw = 200;
[b a] = butter(n, 1, "s");
[bt2, at2] = lp2bp(b, a, Wo, Bw);
[bt3, at3] = lp3bp(b, a, Wo, Bw);

[bt2' bt3']
[at2' at3']

(file #51270, file #51271, file #51272, file #51273)

Tony Richardson <amrichardson>
Wed 14 Apr 2021 12:16:07 AM UTC, comment #8: 

I have attached sstrans.  This is used by the four lp2* functions in the previous comment.

(file #51262)

Tony Richardson <amrichardson>
Wed 14 Apr 2021 12:14:52 AM UTC, comment #7: 

I wrote a new function called sstrans that does the various transformations (lp, hp, bp, bs) in state space.  It is modeled after sftrans which does the transformations in pole-zero space.  I then modified lp2lp, lp2hp, lp2bp, and lp2bs to call sstrans.  Since I am limited to four file uploads at a time, I will upload the four lp2* functions first and then upload sstrans in the next comment.

(file #51258, file #51259, file #51260, file #51261)

Tony Richardson <amrichardson>
Sun 11 Apr 2021 12:08:18 AM UTC, comment #6: 

Alright, I re-implemented all of the functions using a state space approach.  They should be compatible with the MATLAB functions of the same name.  They all include demo code for illustration/testing.

These functions do not use sftrans.  They use tf2ss and ss2tf to transform to/from state-space.  The transformations are carried out in state-space.

(file #51237, file #51238, file #51239, file #51240)

Tony Richardson <amrichardson>
Sat 10 Apr 2021 04:13:46 PM UTC, comment #5: 

After sleeping on this, I wonder if my original implementations (files 51223-51226) might be more robust than the newer ones that use sftrans (files 51227-51230).  They really aren't much uglier than the implementation of sftrans.  I could see moving all of the coefficient transformation code into a common function (kind of like sftrans) so that the implementations of lp2lp, etc are cleaner.

The newer functions use tf2zp to transform from the transfer function (coefficient) representation to the zero-pole representation, sftrans is then used to transform the zero-poles of the prototype filter to those of the desired filter (lp, hp, etc), then zp2tf is used to transform the zeros and poles back to the transfer function (coefficients) of desired filter. The original implementations directly transform the coefficients of the prototype filter to those of the desired filter using polynomial multiplication (conv) operations.  I would think that the direct transformation in the original code would be more accurate than the multiple transformations in the newer code, but I have not tested this at all.  (It seems as if the newer code could also introduce extraneous poles and zeros, but I am not sure.)  The newer code uses existing Octave functions that have been tested over time while the original functions have undergone very little testing.

I would guess that when there are two different algorithms that can be used to implement an Octave function a decision is based on accuracy and robustness (speed wouldn't appear to be much of a concern for these functions).  I'll try to do some more testing of the original functions (maybe refactor and clean up the code a bit) and compare results to the newer functions.

Tony Richardson <amrichardson>
Sat 10 Apr 2021 05:55:28 AM UTC, comment #4: 

I added a slightly modified version of sftrans which works correctly when the input pole and zero vectors are either row or column vectors.  The older version works properly only with row vectors.  Current versions of tf2zp produce column vectors.

(file #51231)

Tony Richardson <amrichardson>
Sat 10 Apr 2021 03:30:55 AM UTC, comment #3: 

My previous functions were so ugly I was motivated to explore using sftrans to implement lp2lp, lp2hp, lp2bp, and lp2bs.  These implementations are much more elegant.  I did run into some issues with sftrans.  It seems to expect the input arguments to be row vectors but tf2zp now produces column vectors.

(file #51227, file #51228, file #51229, file #51230)

Tony Richardson <amrichardson>
Sat 10 Apr 2021 02:34:05 AM UTC, comment #2: 

I have included implementations of lp2lp, lp2hp, lp2bp, and lp2bs.  Each includes demo code.

I worked directly with the coefficient polynomials of the transfer function instead of using any functions from the controls package.  I am sure that there are more efficient implementations of each of the functions (especially for lp2bp and lp2bs), but these seem to work ok.  They may at least provide a starting point for further refinement.

I used examples from the public documentation from the corresponding MATLAB functions for testing (and for the demo code).  I have not seen the code for the MATLAB functions (but I would guarantee they are implemented much differently).

(file #51223, file #51224, file #51225, file #51226)

Tony Richardson <amrichardson>
Fri 20 Nov 2015 03:32:35 PM UTC, comment #1: 

Attached are two Octave m-files, phi2p.m and Hp2g.m that implement frequency transformations using the algorithm of Figure 6.7.3 of "Digital Signal Processing" R.A. Roberts and C.T. Mullis Addison-Wesley ISBN 0-201-16350-0. The script ellip5_test.m does some examples. I would be happy to try and work this up into a format acceptable for the toolbox.

(file #35505)

Robert Jenssen <morgawr>
Fri 13 Nov 2015 09:34:58 PM UTC, original submission:  

from the help list.  User has requested the function and supplied the following as a starting point (also attached):


function [at,bt] = lp2lp(a,b,wo)
  if (nargin==3)
    [z, p, k] = tf2zp (a, b);
    [z, p, k] = sftrans (z, p, k,wo, false);
    [at, bt] = zp2tf (z, p, k);
  else
      print_usage;
  endif
endfunction

*Besides documentation it is necessary to figure out the space state case.*

*Later this year I will do it.*

I'm unfamiliar with the application and intended function, so can't really help here at the moment. User indicated he may have time later to revisit. In the meantime, others familiar with the intent could possible add tests for function and compatibility, etc. --Nick J.

Nicholas Jankowski <nrjank>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #51274:  tftrans.m added by amrichardson (4KiB - text/plain)
file #51270:  lp3lp.m added by amrichardson (2KiB - text/plain)
file #51271:  lp3bp.m added by amrichardson (2KiB - text/plain)
file #51272:  lp3hp.m added by amrichardson (2KiB - text/plain)
file #51273:  lp3bs.m added by amrichardson (2KiB - text/plain)
file #51262:  sstrans.m added by amrichardson (2KiB - application/octet-stream)
file #51258:  lp2lp.m added by amrichardson (2KiB - application/octet-stream)
file #51259:  lp2hp.m added by amrichardson (2KiB - application/octet-stream)
file #51260:  lp2bp.m added by amrichardson (2KiB - application/octet-stream)
file #51261:  lp2bs.m added by amrichardson (2KiB - application/octet-stream)
file #51237:  lp2lp.m added by amrichardson (2KiB - application/octet-stream)
file #51238:  lp2hp.m added by amrichardson (2KiB - application/octet-stream)
file #51239:  lp2bp.m added by amrichardson (3KiB - application/octet-stream)
file #51240:  lp2bs.m added by amrichardson (3KiB - application/octet-stream)
file #51231:  sftrans.m added by amrichardson (8KiB - application/octet-stream)
file #51227:  lp2lp.m added by amrichardson (2KiB - application/octet-stream)
file #51228:  lp2bp.m added by amrichardson (2KiB - application/octet-stream)
file #51229:  lp2hp.m added by amrichardson (2KiB - application/octet-stream)
file #51230:  lp2bs.m added by amrichardson (2KiB - application/octet-stream)
file #51223:  lp2lp.m added by amrichardson (2KiB - application/octet-stream)
file #51224:  lp2bp.m added by amrichardson (3KiB - application/octet-stream)
file #51225:  lp2hp.m added by amrichardson (2KiB - application/octet-stream)
file #51226:  lp2bs.m added by amrichardson (3KiB - application/octet-stream)
file #35505:  phi2p.tgz added by morgawr (2KiB - application/x-compressed-tar - Frequency transformations of a prototype transfer function)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by amrichardson (Updated the item)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by morgawr (Updated the item)
  • -email is unavailable- added by nrjank (Submitted the item)
  • -email is unavailable- added by nrjank
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 25 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-04-15 amrichardson Attached File- => Added tftrans.m, #51274
    2021-04-15 amrichardson Attached File- => Added lp3lp.m, #51270
        Attached File- => Added lp3bp.m, #51271
        Attached File- => Added lp3hp.m, #51272
        Attached File- => Added lp3bs.m, #51273
    2021-04-14 amrichardson Attached File- => Added sstrans.m, #51262
    2021-04-14 amrichardson Attached File- => Added lp2lp.m, #51258
        Attached File- => Added lp2hp.m, #51259
        Attached File- => Added lp2bp.m, #51260
        Attached File- => Added lp2bs.m, #51261
    2021-04-11 amrichardson Attached File- => Added lp2lp.m, #51237
        Attached File- => Added lp2hp.m, #51238
        Attached File- => Added lp2bp.m, #51239
        Attached File- => Added lp2bs.m, #51240
    2021-04-10 amrichardson Attached File- => Added sftrans.m, #51231
    2021-04-10 amrichardson Attached File- => Added lp2lp.m, #51227
        Attached File- => Added lp2bp.m, #51228
        Attached File- => Added lp2hp.m, #51229
        Attached File- => Added lp2bs.m, #51230
    2021-04-10 amrichardson Attached File- => Added lp2lp.m, #51223
        Attached File- => Added lp2bp.m, #51224
        Attached File- => Added lp2hp.m, #51225
        Attached File- => Added lp2bs.m, #51226
    2019-02-26 mtmiller Assigned tomtmiller => None
        Releaseother => dev

    Back to the top


    Powered by Savane 3.6