MATLAB Answers


function coder.newtype not supported for code genertion

Asked by Tamar Harpaz on 17 Apr 2019
Latest activity Commented on by Ryan Livingston on 19 Apr 2019
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.


Sign in to comment.




1 Answer

Answer by Ryan Livingston on 17 Apr 2019

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.


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.
Thanks again.
I implemented your advice.
but a little problem for that 2 first lines:
hrtfDB= load ('ReferenceHRTF.mat');
The output of a call to 'load' is not assigned to a variable. Assign its output to a variable without subscripting when adding hrtfDB to the coder.const too.
Rather than:
hrtfDB= load ('ReferenceHRTF.mat');
Try using:
hrtfDB = coder.load ('ReferenceHRTF.mat');
hrtfData = hrtfDB.hrtfData;

Sign in to comment.