Codegen fails with "wrong number of input arguments" while function calls without error
显示 更早的评论
I'm trying to generate a mex file for the following function:
function matInt = testfun(a,b,M)
matfun = @(x) squeeze(interpn([-1 0 1],[-1,0,1],M,x(1),x(2)));
matInt = integral(@(s) matfun(a*s+(1-s)*b), 0, 1, 'ArrayValued',true);
end
using the following script:
clear; close all;
%% Test arguments
a = [.5;.3];
b = [-.2;-1];
M = randn(3,3,5,5);
%% Run function
Mint = testfun(a,b,M); % okay
%% Codegen
% error:
codegen testfun -args {a,b,M}
Running the function (so computing Mint) goes fine without any errors. But generating a mex file using the same input arguments (in the last line) throws the error:
??? Wrong number of input arguments.
Error in ==> testfun Line: 2 Column: 23
Code generation failed: View Error Report
I'm not exactly what goes wrong there, as I do not see how I do not give the correct number of input arguments.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Algorithm Design Basics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!