MATLAB Answers

First argument must be a vector.; Function call failed.

21 ビュー (過去 30 日間)
I am trying to conver a function to C using coder. I am using inbuilt function 'filtfilt'. Function executes properly but when i try to convert it to C i get following errors:
1.Function call failed.
2.First argument must be a vector.
3. Undefined function or variable 'W'. The first assignment to a local variable determines its class.
for this line in function:
W= filtfilt(digfilt1,1,y1);
where digfilt1 and y1 are both of type double.
Can anyone help me

  2 件のコメント

Darshan Ramakant Bhat
Darshan Ramakant Bhat 2020 年 7 月 16 日
Can you please attache a script to reproduce the issue ?
  • Provide the MATLAB function which is giving this error.
  • Steps / commands that you are using to generate code for the above function.
This will help us to reproduce the issue.
Darshan Ramakant Bhat
Darshan Ramakant Bhat 2020 年 7 月 16 日
What is the value of input y1 in the above function ?

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

採用された回答

Darshan Ramakant Bhat
Darshan Ramakant Bhat 2020 年 7 月 16 日
I can see that you are using MATLAB R2018a. The codegen support for filtfilt is improved significanlty in the later releases.
I tried the below command in R202a and it is working fine for me :
>> codegen -config:lib filtfilt -args {0,1,1:2} -report
Hope this is helpful for you.

  1 件のコメント

Sohan poul
Sohan poul 2020 年 7 月 16 日
oh ok thank you...

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

その他の回答 (2 件)

Wilson A N
Wilson A N 2020 年 7 月 16 日
編集済み: Wilson A N 2020 年 7 月 16 日
Hi Sohan,
In R2018a, the filtfilt function needs its input arguments to be constant or not changing. You can see the 'Extended Capabilities' section which says the same for R2018a.
Here the variable 'y1' you have used is not constant and its dimensions are also not determined at compile time. Hence you get this error.
Starting from R2019b, filtfilt is enhanced for code generation which will help in these inputs.
Regards,
Wilson

  2 件のコメント

Sohan poul
Sohan poul 2020 年 7 月 16 日
y1 is a set of constant double values imported through .csv file
Wilson A N
Wilson A N 2020 年 7 月 16 日
I see. But since 'y1' is being passed into the function, coder might not have inferred 'y1' as a constant.
If 'y1' is indeed a constant, try putting the values (u can start with a small subset) inside the function and then call codegen on the function containing filtfilt.

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


Sohan poul
Sohan poul 2020 年 7 月 16 日
I tried it still I get same errors.

  1 件のコメント

Darshan Ramakant Bhat
Darshan Ramakant Bhat 2020 年 7 月 16 日
Can you please try in the newer release R2020a or R2019b ? As Wilson mentioned, there were many limitations for this function codegen support earlier.

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

カテゴリ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by