Please explain Coder run-time errors
1 次查看(过去 30 天)
显示 更早的评论
I admit I'm new and ignorant of both Matlab and Coder, but like everybody else, I have a project to do. I'm trying to convert some .m files to .c files so I can use them in an embedded project. I've been provided the code by another engineer. I just have to make it work.
As a .m script, this works well. It runs through Coder without issue. The report, such as it is, says everything is just ducky. When I run the _mex equivalent, I get:
if true
% code
endendTrial>> wrapTo2Pi_mex 4.3
Incorrect class for expression 'lambda': expected 'double' but found 'char'.
Error in wrapTo2Pi_mex
I might be able to figure this out on my own if I knew WHERE in the code the problem occurred.
(I just noticed the (C) Mathworks in the code, so presumably this code is properly constructed, and it does seem to work).
Can anybody decode the error for me? Thanks in advance from someone who will never be as good at Matlab as you are right now.
Herewith the code:
if true
% code
endendfunction lambda = wrapTo2Pi(lambda)
%wrapTo2Pi Wrap angle in radians to [0 2*pi]
%
% lambdaWrapped = wrapTo2Pi(LAMBDA) wraps angles in LAMBDA, in radians,
% to the interval [0 2*pi] such that zero maps to zero and 2*pi maps
% to 2*pi. (In general, positive multiples of 2*pi map to 2*pi and
% negative multiples of 2*pi map to zero.)
%
% See also wrapToPi, wrapTo180, wrapTo360.
% Copyright 2007-2008 The MathWorks, Inc. % $Revision: 1.1.6.1 $ $Date: 2008/12/22 23:50:53 $
positiveInput = (lambda > 0); lambda = mod(lambda, 2*pi); lambda((lambda == 0) & positiveInput) = 2*pi;
采纳的回答
Ryan Livingston
2017-7-14
编辑:Ryan Livingston
2017-7-14
wrapTo2Pi_mex(4.3) is the right syntax to pass a double precision number to wrapTo2Pi_mex. The code wrapTo2Pi_mex 4.3 passes the char array '4.3' similar to a command-line executable.
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!