Code generation of an S-function with multiple inputs and outputs
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi. As a follow up to my previous query, I'm now trying to generate a dll from an S-function that takes in three inputs and returns 3 outputs. This is based on the following equations :

Where V, alpha and beta are the inputs into the S-function block and u,v and w are the outputs respectively. I'm getting the right results whenever I run the simulation but upon code generation, I'm getting the following error messages:
warning C4013: 'cos' undefined; assuming extern returning int
error C2143: syntax error: missing ')' before ';'
I have attached relevant snippets of the S-function code as well as the generated C code respectively below:
M file:
V = block.InputPort(1).Data;
alpha = block.InputPort(2).Data;
beta = block.InputPort(3).Data;
u = block.OutputPort(1).Data;
v = block.OutputPort(2).Data;
w = block.OutputPort(3).Data;
u = V * cos(alpha) * cos(beta);
v = V * sin(beta);
w = V * sin(alpha) * cos(beta);
C :
rtb_Level2MATLABSFunction_o1 = simpleflight_U.V * (cos(simpleflight_U.V) *
(cos(simpleflight_U.V));
rtb_Level2MATLABSFunction_o2 = simpleflight_U.V * (sin(simpleflight_U.V));
rtb_Level2MATLABSFunction_o3 = simpleflight_U.V * (sin(simpleflight_U.V)) *
(cos(simpleflight_U.V));
As you can see, in addition to the error messages, only one of the three inputs is being used in the generated c code.
I have also attached the tlc file below for further reference:
%implements "vab_to_uvw1" "C"
%% Function: Outputs ===========================================================
%%
%function Outputs(block, system) Output
/* %<Type> block: %<Name> */
%assign rollVars = ["U", "Y"]
%roll idx = RollRegions, lcv = RollThreshold, block, "Roller", rollVars
%assign V = LibBlockInputSignal(0, "", "", 0)
%assign alpha = LibBlockInputSignal(0, "", "", 1)
%assign beta = LibBlockInputSignal(0, "", "", 2)
%assign u = LibBlockOutputSignal(0, "", lcv, idx)
%assign v = LibBlockOutputSignal(1, "", lcv, idx)
%assign w = LibBlockOutputSignal(2, "", lcv, idx)
%<u> = %<V> * (cos(%<alpha>) * (cos(%<beta>));
%<v> = %<V> * (sin(%<beta>));
%<w> = %<V> * (sin(%<alpha>)) * (cos(%<beta>));
%endroll
%endfunction
Has anybody encountered this issue before? Any help would be great.
Thanks in advance.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Target Language Compiler finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!