Errors occurred during parsing of MATLAB function 'sine1'(#23)
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm trying to use 'MATLAB Function' under 'User-Defined Functions' on Simulink Library Browser to write something like,
function y = sine1(u) %#codegen
global n m g C1 C2 C3
y=zeros(size(u));
for i=1:numel(u)
if u(i) <= -g
y(i) = n*u(i)./m + g*n/m;
elseif u(i) >= -g && u(i) <= g
y(i) = C1*sin(pi*u(i)./g+pi)+C2*sin(2*pi*u(i)./g+pi)+C3*sin(3*pi*u(i)./g+pi);
else
y(i) = n*u(i)./m - g*n/m;
end
end
end
Global variables are called from another m file and u is a vector and other variables are scalar. When I run it, I get this error message: Errors occurred during parsing of MATLAB function 'sine1'(#23).
Does anyone know what is causing this issue? I'm also curious to know what this #23 means. I can't seem to find anything online so far. Any help would be very helpful. Thank you.
1 个评论
Ryan Livingston
2014-7-1
Is there any more information in the error message? Typically, it should list a line number on which the error was detected. From what I've seen the #23 should be a hyperlink back to the location of the error in your MATLAB code.
Also, you can try putting the code into an M file and running it in MATLAB to pinpoint the location of the error.
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!