How to create a sawtooth signal inside an S-function ?
이전 댓글 표시
Hi,
I'm working with C-MEX S-function (C code). I was wondering if it is possible to create a sawtooth signal inside a C-coded S-function and see the signal with the Simulink scope. If it is possible, how to do it ?
Thanks for your help
채택된 답변
추가 답변 (1개)
Alice
2012년 9월 14일
0 개 추천
댓글 수: 3
Alice
2012년 9월 17일
TAB
2012년 9월 17일
In your S-function builder block
- 1 output (y[0]) for LED,
- 1 input (u[0]) for comparing
- 1 discrete state (xD[0]) for storing Ramp value
- No continuous state.
In your S-function builder Discrete update field
xD[0] = xD[0] + 1;
if(xD[0]>=UPPER_LIMIT)
{
xD[0] = 0;
}
In your S-function builder Outputs field
if(xD[0]>=u0[0])
{
y0[0] = 1; /*LED ON*/
}
else
{
y0[0] = 0; /*LED OFF*/
}
Please go through the s-function document.
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!