How can i use sign function under a function block in simulink ?

조회 수: 33 (최근 30일)
Mustafa
Mustafa 2014년 4월 23일
댓글: Zhe Chen 2020년 4월 3일
Hey guys, i'm new in using simulink. And i have a problem by using "sign(signum)" fucntion, in a fucntion block. When i write my formula inside the function block and run it. I have syntax error. But i'm pretty sure i wrote the formula correct. And when i remove sign function from the formula, it works(but not correctly). So how can i use this "sign" fucntion inside a function block ? Please help me i'm stuck in a project right now. Thank you
  댓글 수: 2
Mustafa
Mustafa 2014년 4월 23일
/matlabcentral/answers/uploaded_files/11756/Capture.JPG The only reason why i got error is "sign" function. Because when i removed it from the equation, it works. And i dont know where i make mistake

댓글을 달려면 로그인하십시오.

답변 (2개)

A Jenkins
A Jenkins 2014년 4월 23일
Is that the full equation? Your parentheses don't match. (7 open and only 6 close)
Perhaps should be
(-Kc*u(1)-Bc*u(4)+Kc*u(2)/N-Fc*sign(u(5)+u(9)))/Jcin
  댓글 수: 2
Mustafa
Mustafa 2014년 4월 23일
편집: Mustafa 2014년 4월 23일
Thank you very much.I made the correction, but still i got syntax error in the same function block :/
A Jenkins
A Jenkins 2014년 4월 23일
Check that all of your parameters, Kc, Bc, etc are defined.
Also check that your input signal u, has a width of at least 9.

댓글을 달려면 로그인하십시오.


Luuk Ladegaard
Luuk Ladegaard 2018년 9월 24일
Hey, I don't know whether you're still struggling with this problem, but I discovered that for some reason, you need to use "sgn()" instead of "sign()". I have no idea what's up with that, it's not an existing Matlab function, but it works in Simulink. I guess it's a mistake. :/
  댓글 수: 1
Zhe Chen
Zhe Chen 2020년 4월 3일
I have the same problem. And your method works.
I dont know either why is that when I changed the sign function to sgn, the syntax error goes away.

댓글을 달려면 로그인하십시오.

카테고리

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