function coder.newtype not supported for code genertion
古いコメントを表示
Hello friends,
Matlab coder asked me to make a input variable (for a function) as constant by using newtype.
After I did it, it says that the coder.newtype is not supported.
Anyone?
Thanks
回答 (1 件)
Ryan Livingston
2019 年 4 月 17 日
Can you elaborate on where you used coder.newtype? If using the codegen command you can:
codegen myFunction -args {coder.typeof(1,[10,20],[0,1])}
To pass a constant input use:
codegen myFunction -args {coder.Constant(magic(3))}
Lastly, can you copy and paste the exact error message you're getting? It seems like something we could improve.
6 件のコメント
Tamar Harpaz
2019 年 4 月 18 日
編集済み: Tamar Harpaz
2019 年 4 月 18 日
Ryan Livingston
2019 年 4 月 18 日
Got it. The issue is the call to coder.Constant. That is meant to be used as an input to codegen not in your MATLAB code. For example:
codegen myFunction -args {coder.Constant(1), otherArg}
If you'd like to forcibly constant fold something inside your MATLAB code, you should instead use coder.const
function y = foo()
y = coder.const(svd(magic(30)));
end
Tamar Harpaz
2019 年 4 月 18 日
編集済み: Tamar Harpaz
2019 年 4 月 18 日
Ryan Livingston
2019 年 4 月 19 日
For coder.const to succeed, the input to it must be able to have a constant value computed for it. Look back through your code to find the variables that lead to the value of leftIR. Test each one of those with coder.const to find the root value which is non-constant.
Glancing over the code it looks like one of the dependencies leads to load. The output of load is never constant. You can instead try coder.load which always produces a constant value rather than load which is a runtime value.
Tamar Harpaz
2019 年 4 月 19 日
Ryan Livingston
2019 年 4 月 19 日
Rather than:
hrtfDB= load ('ReferenceHRTF.mat');
hrtfData=coder.const(hrtfDB.hrtfData);
Try using:
hrtfDB = coder.load ('ReferenceHRTF.mat');
hrtfData = hrtfDB.hrtfData;
カテゴリ
ヘルプ センター および File Exchange で Function Definition についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!