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 Center および File ExchangeSimulink についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by