Errors occurred during parsing of MATLAB function 'sine1'(#23)

조회 수: 1 (최근 30일)
Sumin
Sumin 2014년 6월 24일
댓글: Ryan Livingston 2014년 7월 1일
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
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개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by