Getting Error while implementing Filter object.

7 ビュー (過去 30 日間)
Riyasat
Riyasat 2017 年 3 月 3 日
編集済み: Walter Roberson 2017 年 3 月 4 日
Hello,
I am using the Digital Filter with properties. I have defined 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.
  4 件のコメント
Walter Roberson
Walter Roberson 2017 年 3 月 4 日
I am not all that familiar with designfilt. It would be easier if you could give specific commands to create a filter that you have difficulty with, or if you were to attach the .mat that had the stored filters.
Riyasat
Riyasat 2017 年 3 月 4 日
編集済み: Riyasat 2017 年 3 月 4 日
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
filt = D_sig50
for example. (Depends on a conditional if-else structure which filter would be selected.)
I have also, attached the variable x as a .mat file.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2017 年 3 月 4 日
When I design a filter matching the specifications of D_sig50(1), I see for it
FilterFunction: @filterIIR
FiltfiltFunction: @filtfiltIIR
GetCoefficientsForAnalysisFunction: @getCoeffsForAnalysisIIR
whereas for the loaded objects
FilterFunction: []
FiltfiltFunction: []
GetCoefficientsForAnalysisFunction: []
So either the filter functions were not saved or else the saved function reference could not be located at the time of reload of the objects and [] was substituted.
... Experimenting with a few back releases, I find that the filters work if you load them in R2015a, but not if you load them in R2015b.
  3 件のコメント
Walter Roberson
Walter Roberson 2017 年 3 月 4 日
編集済み: Walter Roberson 2017 年 3 月 4 日
Load the file. Then
filt = D_sig50(1);
sf = struct(filt) ;
sf.FilterFunction
The field does not exist in R2015a because the implementation was different
Riyasat
Riyasat 2017 年 3 月 4 日
編集済み: Riyasat 2017 年 3 月 4 日
I think this was the issue. I generated the filters again in MATLAB 2016a, and now it's working properly. Thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFilter Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by