Multiple outputs using Legacy Toolbox

5 ビュー (過去 30 日間)
Pierre-Olivier Desrosiers
Pierre-Olivier Desrosiers 2022 年 8 月 9 日
コメント済み: Jeremy 2023 年 3 月 31 日
Hi, i'm currently working on a project and I have to create a s-function written in C language. I have multiple outputs (V, m, h & fm) and multiple inputs(q1, q2, qe & qo). Here's my main file:
#include "Reservoir.h"
#include <math.h>
double Reservoir(double q1,
double q2,
double qe,
double qo,
double *V,
double *m,
double *h,
double *fm)
{
*V = q1 + q2 + qe - qo;
*m = 1875.0 * q1 + 1667.0 * q2 + 1000.0 * qe - 1468.48 * qo;
*h = sqrt(*V + 1) - 1;
*fm = ((3000.0) * (1 - 1000.0)) / ((3000.0 - 1000.0) * (*m/*V))
}
And here's my header file :
#ifndef RESERVOIR_H_INCLUDED
#define RESERVOIR_H_INCLUDED
double Reservoir(double q1, double q2, double qe, double qo, double *V, double *m, double *h, double *fm);
#endif // RESERVOIR_H_INCLUDED
I'M also working with Legacy Toolbox to generate a tlc file and the s-function. I'm using these lines to generate the s-function :
def = legacy_code('initialize')
def.SFunctionName = 'S_function1'
def.OutputFcnSpec = 'Reservoir(double q1, double q2, double qe, double qo, double *V, double *m, double *h, double *fm)'
def.HeaderFiles = {'Reservoir.h'}
def.SourceFiles = {'main.c'}
legacy_code('sfcn_cmex_generate', def)
When i execute the last line, i receive this error :
Error using legacycode.LCT.legacyCodeImpl
Unrecognized elements in the function specification:
--> Reservoir(double q1, double q2, double qe, double qo, double *V, double *m, double *h, double *fm)
Error in legacy_code (line 103)
[varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
Thus, I was wondering what i've done wrong ? Thanks for your help.
  1 件のコメント
Jeremy
Jeremy 2023 年 3 月 31 日
running into a similar issue. unsure if the fix will be the same as I am incorporating a struct in the args as a simulink.bus obj, but legacy tool returns a successful import of that. Commenting in hope someone returns to this question.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by