Simulink S-function builder reading inputs

Hello all,
I have just started to learn how to implement the S-functions via
the Simulink S-function builder. I have been attempting to model
a discrete system with two 1-D inputs (act and ref) and one
1-D output (u). My C language code for the outputs calculation is
following
double ref;
double act;
double e;
e = ref - act;
u[0] = e;
The building process is successful but whenever I start the simulation
process there is zero at the S-function block output despite the fact
that the ref input is non-zero.
I have also tried a different version of C code:
double ref;
double act;
double e;
e = ref[0] - act[0];
u[0] = e;
But in that case I was not able to build the code.
Can anybody tell me what I have been doing wrong?

回答(1 个)

"u" is usually referred as inputs, "y" is usually referred as outputs.
You need to go through the S-Function Builder Dialog Box to fill the info and copy&paste your C code.

类别

在 帮助中心 和 File Exchange 中查找有关 Block and Blockset Authoring 的更多信息

产品

版本

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by