S-Function Builder Outputs

5 views (last 30 days)
Mark
Mark on 29 Nov 2012
Hello everyone, i think my problem is pretty simple, but I just can't figure out the problem. I want to build a standard S-Function with the help of the S-Function Builder. I have 4 Inputs, 4 Parameters and 2 Outputs. I entered my Inputs and Parameters in the respective fields in the Sfun-Builder. My formula for the output look like this: Tho = (Pel + Mh * Thi * c + Ms * Tsi * c - (Ms * c * (sqrt(pow(CG,2) * pow(Ms,2) * pow(Pel,2) + 4 * CG * pow(Mh,2) * Ms * Pel * Thi * c + 4 * CG * pow(Mh,2) * Ms * Pel * c * k + ... (its pretty long but it goes on like the part i posted).
When i click on "Build" in the Sfun-Builder i get a lot of errors but they are mostly the same. All refering to the line with my formula. The errors are:
error C2296 '*' : illegal, left operand has type 'const real_T *'
error C2297 '*' : illegal, right operand has type 'const real_T *'
error C2440 'function' ; cannot convert from 'const real_T *' to double
warning C4024 'pow' : different types for formal and actual parameter 1
I get these errors all over again until the error count exceeds 100 and the compiling stops. I need this to run for an important work! So please help me out here =)

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 29 Nov 2012
Hi,
please keep in mind, that Simulink (and S-Function Builder) assumes all signals to possibly be vector valued. Therefore, all inputs and outputs are arrays. You will need to write e.g. PEL[0] instead of PEL.
Titus
  1 Comment
Mark
Mark on 29 Nov 2012
Works perfectly! Thank you very much, Titus!

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!