Matlab, error while trying to implement a Filter object

Rio1210

I am using the Digital Filter with properties in MATLAB. I have designed this filter using designfilt. I have defined the filter object filt(1) as:

 digitalFilter with properties:
            Coefficients: [20x6 double]
   Specifications:
       FrequencyResponse: 'bandpass'
         ImpulseResponse: 'iir'
              SampleRate: 1000
      PassbandFrequency1: 59.9000
          PassbandRipple: 3
    StopbandAttenuation2: 80
    StopbandAttenuation1: 80
      PassbandFrequency2: 60.0800
             FilterOrder: 40
            DesignMethod: 'ellip'

Similarly, I have other filters under filt object as filt(2), filt(3) upto filt(8) each at different frequencies.

Now, for some reason I get the error, when my program tries to run the line:

Q = filter(filt(1),x);

where, x is a 600000x1 column vector with only positive and negative real values (resembling a long sine wave)

The error that I get is:

Subscript indices must either be real positive integers or logicals.

Error in digitalFilter/filter (line 870)
    y = obj.FilterFunction(obj.Coefficients,x);

Could anyone please point out the problem? Thanks a lot.

EDIT:

The

designfilt

command opens up an interactive interface where you can change and tune your filter requirements. I have optimized the filters, and saved the results as a .mat file. [This whole program used to work, was part of a significant project which we completed succesfully, but after a year doesn't seem to work somehow.]

I have attached the filter_8th.mat file. There are various filters here. I have already created these filters before hand because Matlab takes a lot of time to create these.

In this .mat file, the filter objects are named as D_n1_50, D_n1_60, D_sig50, D_sig60 etc. (easily recognizable from the Workspace.)

The line of code that assigns these filter to the variable filt is, for example:

filt = D_sig50

This is being selected in a loop. Which filter will be selected depends on a conditional if-else structure.

the .mat file containing "filters" and the variable "x" are in this dropbox link:

Rio1210

The issue has been resolved. This is due to the absence of the filter object fields:

                    FilterFunction:
                  FiltfiltFunction:
GetCoefficientsForAnalysisFunction:

In MATLAB 2015a these fields are absent from the filters objects. But in MATLAB 2016a (which is I am using, these fields seem to be required.) As the files were imported after creation in MATLAB 2015a, that seems to be the problem. Recreating, the fields in MATLAB 2016a solved the issue. The fields have also been created.

The code ran to check:

filt = D_sig50(1);
sf = struct(filt) ;
sf.FilterFunction

Created in MATLAB 2015a: output:

                    FilterFunction: []
                  FiltfiltFunction: []
GetCoefficientsForAnalysisFunction: []

These fields in the filter object are empty (after loading these filters in MATLAB 2016a)

Created in MATLAB 2016a:

                    FilterFunction: @filterIIR
                  FiltfiltFunction: @filtfiltIIR
GetCoefficientsForAnalysisFunction: @getCoeffsForAnalysisIIR

The fields are now present in the filter object, and the code works now.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Trying to do a filter method on an object

Validation error while trying to parse a json array to List[Object] in Scala

error while trying to implement master details table

Getting error while trying to render array of object in react js

Error while trying to load a JSON object with python 3

Trying to implement the difference formula in MATLAB

Getting error Cannot find a differ supporting object '[object Object]' of type 'object' while trying to populate list of objects

Trying to implement Gaussian Filter in C

Javascript doesn't throw error while trying to call get on an object

Invalid Object error while trying to perform a SQL query

Getting Error Trying to Implement Object Detection with Tensorflow

Error when trying to Set custom Object while looping through a Collection

Getting Error : lvalue required while trying to implement a Jagged Array in C

Macro error while trying to implement a trait inside a macro expansion

Reshape error while trying to store values in a vector in MATLAB

Getting error while trying to implement Recursion with arrays

error trying to filter a field

Error while trying to implement ClickListener in Recyclerview

Error while trying to rotate polar plot in Matlab

Data type mismatch in criteria expression error while trying to filter report

'ManyToManyDescriptor' object has no attribute 'filter in Django while trying add item to favorite

Facing compiler error while trying to implement minimalist architecture using ValueNotifier and ValueListenable

Swift error while trying to implement a search bar

An error while trying to implement a polynomial regression with Pytorch - Gradients are None after loss.backward()

gremlin_python query 'object is not callable' error when trying to filter

search filter in React giving error while trying to use state hooks

Error thrown while trying to update linq-to-sql object

Error while trying to implement custom functions

NestJS Error while importing a module while trying to implement JWT

TOP Ranking

HotTag

Archive