Re: compile C S-Function which uses MEX calls with RTW



Titus wrote:



"riccardo" <nothx@xxxxxxxxxx> schrieb im Newsbeitrag
news:ef5dc10.0@xxxxxxxxxxxxxxxxxxxxxxxxxx
Titus wrote:


Hi Bert,

you are (unfortunately) right, RTW does not support
structure
arguments to
S-functions.
For the second question: first of all, do you really need
the
inverse or are
you solving some
system of linear equations. In the latter case, use \
instead of
inv (in
MATLAB). And: no,
you don't need to code this your self, use the Embedded
MATLAB
function
block for
this kind of problems.

Titus

"Bert " <bert.vandersmissen@xxxxxxxxxxxx> schrieb im
Newsbeitrag
news:f7i13j$nma$1@xxxxxxxxxxxxxxxxxxxxx
Hello,

I have a C S-Function which works fine in Simulink and
which I
now would
like to compile to a dSpace system using RTW. The
S-Function
gets
its
parameters out off the Matlab workspace via a structure
variable.
The
S-Function also uses Mex functions (a.o. mxGetField to
get the
data out of
the structure, mxGetPr, mxGetM, mxGetN, mxSetM, mxSetN,
mexCallMatlab to
use Matlab's inv function).

Apparently some of these mex functions are not
supported by
RTW.
How can I
adapt my S-function to make it compile with RTW? Can I
still
use
the
Matlab structure as a parameter? Do I have to code the
matrix
inverse
function inv myself in C?

Thanks in advance,
Bert





Hi Bert,

what sort of application are you building ?
If it's RT critical - like most of those running on dSpace HW -
you
should actually:
1) not have your Simulink s-function directly included in it,
but
instead write a companion TLC file to produce the C-source
implementing its functionality - i.e. have a "fully inlined
s-function";
2) any mx... / mex.... API call has no place in an embedded
environment (would you really want to run Matlab on it ?), no
surprise, for once, that RTW doesn't support it;
3) I suspect the Embedded Matlab block (embedding Matlab calls
in
Simulink) may not be that good again in case of a RT target;
4) you will have to replace "inv" calls with some suitable
alternative algorithm using supported algebraic operations
(plenty of
functions in the standard rtlib library, and you may include an
additional external library if you want/need it).
HTH

Riccardo

Hi,
I agree with the exception of 3): the Embedded MATLAB function
block is not to be mixed up with the MATLAB function block.
The Embedded MATLAB function block supports only a subset
of MATLAB (for details see doc), but translates the MATLAB
code to embeddable C-code...

Titus




Hi Titus,

My fault the mixup: never used the block - actually never seen it as
I've always been using R13 SP1 for autocoding.

Anyway, forgive me but I would still go for an inlined s-function.

Riccardo
.



Relevant Pages

  • Re: Subscripting into an mxArray in EML
    ... Embedded MATLAB currently requires that it determine constant sizes for all ... MATLAB variables diring compilation. ... Embedded MATLAB function yet, i.e., because the size of its output depends ... plan to support this hyper-important MATLAB function, and dynamic sizing, ...
    (comp.soft-sys.matlab)
  • Re: support embedded matlab function
    ... Embedded MATLAB is a relatively recent development. ... FOO is a MATLAB toolbox function that is not ... Does optimization toolbox support ...
    (comp.soft-sys.matlab)
  • Re: Why no 64-bit support for Mac OS?
    ... Leopard is the first OS X release to have 64-bit libraries "top to ... bottom" (Tiger 10.4 only had 64-bit support in the BSD Unix layer, ... which is used heavily by MATLAB Desktop and many ... Intel Core 2 Duo or Xeon processors support 64-bit; ...
    (comp.soft-sys.matlab)
  • Re: flexlm problems - trying to run matlab.
    ... > support page. ... was due to this bug - a bug which your support pages says is a bug in ... I have now solved the Matlab installation problem. ... >>the licence files can be combined, but I have never worked out how. ...
    (comp.sys.sun.admin)
  • Re: Replacement for "FIND" function in Embedded Matlab
    ... % Output IDX is a column vector with numelelements. ... The usual solution in Embedded MATLAB ... to write a loop and do things the way you'd do them in almost any other ...
    (comp.soft-sys.matlab)

Loading