add a function to a model
이전 댓글 표시
Hi, I develop a function in matlab code:
function u = f(y)
if (u>0.8)
y=1;
elseif (u<0.8)
y=-1;
else
y=0;
where u is a random signal generate with the random number block. How can i join these two blocks? (random number and a block which contain my function without errors). I try using level-2 matlab s-function but it make error. can i use another block in which i introduce my matlab function code?
Thanks in advance. Néstor
채택된 답변
추가 답변 (2개)
Daniel Baboiu
2011년 11월 3일
0 개 추천
If a function is coded as function u = f(y), then y is the argument and u is the return value. Your block of code does it the other way around.
Jon
2011년 11월 3일
0 개 추천
Have you tried using a 'MATLAB Function' block? Under 'User-Defined Functions'.
u will be your input port and y will b your output port.
카테고리
도움말 센터 및 File Exchange에서 User-Defined Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!