bugGNU Octave - Bugs: bug #40155, signal package: zp2sos return...

 
 

bug #40155: signal package: zp2sos return value is not compatible with Matlab

Submitted by:  None
Submitted on:  Tue 01 Oct 2013 01:17:39 PM UTC  
 
Category: Octave Forge PackageSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: None
Originator Name: Mike FontesOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.4
Operating System: Any

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Sun 26 Jan 2014 09:47:48 PM UTC, comment #6:

This bug is fixed with the following changeset:

http://sf.net/p/octave/signal/ci/f248ba

This fix will be part of the next signal package release.

Mike Miller <mtmiller>
Project Member
Wed 09 Oct 2013 03:32:00 AM UTC, comment #5:

I had someone run the following in Matlab:

Here are the results. As I suspected, the return value of zp2sos depends on the number of output arguments. If the caller does not request the gain as a separate value, it is incorporated into the sos array.

Mike Miller <mtmiller>
Project Member
Wed 02 Oct 2013 12:03:26 AM UTC, comment #4:

Note that zp2sos has two output arguments, the second output argument is the gain.

It may be that Matlab's zp2sos returns a different value for sos depending on whether one or two output arguments are requested. Octave's does not.

Mike Miller <mtmiller>
Project Member
Tue 01 Oct 2013 05:28:35 PM UTC, comment #3:

would someone with matlab try this code:

N=7;
Wn=.4;
res='low';
[Z,P,K]=butter(N,Wn,res);
sos=zp2sos(Z,P,K) % Convert ZP to SOS

in Octave with this code I get:
N=7;
Wn=.4;
res='low';
[Z,P,K]=butter(N,Wn,res);
sos=zp2sos(Z',P',K) % Convert ZP to SOS

sos =

1.00000 2.00000 1.00000 1.00000 -0.33284 0.07708
1.00000 2.00000 1.00000 1.00000 -0.38797 0.25551
1.00000 2.00000 1.00000 1.00000 -0.51008 0.65067
1.00000 1.00000 -0.00000 1.00000 -0.15838 0.00000

Doug Stewart <dastew>
Tue 01 Oct 2013 04:19:02 PM UTC, comment #2:

I think the problem is in the filter functions

The error line is:
sos=zp2sos(Z,P,K); % Convert ZP to SOS

when I change it to
sos=zp2sos(Z',P',K); % Convert ZP to SOS
then it is OK.

the zp2sos is expecting column vectors but the filter designs
are giving row vectors. Matlab says the they use column vectors.

I did not look at the gain problem yet.
Doug

Doug Stewart <dastew>
Tue 01 Oct 2013 01:51:43 PM UTC, comment #1:

Hi Mike, you have posted to the Octave bug tracker, but your message seems more suited to the help list (help-octave@octave.org). You have not identified a specific bug, not that there aren't any bugs in the signal package. There are probably at least 2 bugs at work here. Our goal is indeed to make the signal package compatible with Matlab.

I can confirm your results by running the attached script, but that's as far as I've gone with it.

Please ask your question on the help mailing list instead, which is read by many more people who can better help you with what you are working on.

I'll leave this open for now, but there is not much that can be done here until you can identify which particular function(s) are giving different results from Matlab. Please do try to find those differences if you want to help improve the quality of the Octave signal package.

Mike Miller <mtmiller>
Project Member
Tue 01 Oct 2013 01:17:39 PM UTC, original submission:

I am using the eziir32.m script designed by TI to create iir filter coefficients for use with the TI libraries. They were designed to run under Matlab, but they also run under Octave, using the signals package. There are two problems I have noticed:

1. Some runs of the script cause errors in the Octave environment and produce valid results in the Matlab environment.

2. Some runs of the script produce valid, but very different results in the two environments.

My big issue is with choice number 2 because the results are very different, and are causing representation and overflow issues in the code written using the libraries. I have attached a file which contains the results of a Matlab and an Octave run for the same script inputs. The Matlab run normalizes the filter gain to 1 and scales the coefficients accordingly. The Octave run gives me a gain of over 1100 and totally different coefficients.

I need to get the normalized output to keep the filter representation from losing accuracy due to rounding. A few questions come to mind:

1. What is different between the two packages that cause the large differences in the results created?

2. Are there steps that can be taken to normalize the Octave output and supply a set of coefficients similar to those from Matlab?

3. Is the signal package compatible with Matlab, or similar to Matlab when using the functions in the script.

Can someone please contact me to discuss this. I do not have Matlab and I am relying on Octave to provide me with the coefficients for my filters. I need to know how to successfully get workable values in a normalized form.

Sincerely,

Mike Fontes
-unavailable-

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #29279:  eziir32.m added by None (7kB - application/octet-stream)
file #29280:  Octave and Matlab output and files for IIR.doc added by None (306kB - application/msword)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by dastew (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 8 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 26 Jan 2014 09:47:48 PM UTCmtmillerStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Wed 09 Oct 2013 03:32:00 AM UTCmtmillerStatusNeed Info=>Confirmed
      SummaryOctave does not produce same results as Matlab for iir scripts=>signal package: zp2sos return value is not compatible with Matlab
    Tue 01 Oct 2013 01:51:43 PM UTCmtmillerStatusNone=>Need Info
      Operating SystemMicrosoft Windows=>Any
    Tue 01 Oct 2013 01:17:39 PM UTCNoneAttached File-=>Added eziir32.m, #29279
      Attached File-=>Added Octave and Matlab output and files for IIR.doc, #29280

    Back to the top


    Powered by Savane 3.1-cleanup