Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ppval in simulinks embedded matlab function block

67 views
Skip to first unread message

trabbie

unread,
Dec 5, 2011, 10:10:09 AM12/5/11
to
Hello,

I am bit stuck here. I try to use the matlab function "ppval" in an embedded matlab function block in Simulink, but this is obviously not working, since it is not officially supported in the embedded matlab function library.

Therefore I tried different things.

1. copying the code, which underlies the ppval.m, into the embedded matlab function file might be a way and using it as a function (e.g. name it ppval_int()). The same way with the function unmkpp(), as it is not officially eml-compatible. I just copied the code from unmkpp.m into my original function file as another function.
The only obstacle is to make this code being compatible for using in an embedded matlab environment. trying this as a first shot fails due to the statement (and others)
if length(sizexx)==2&&sizexx(1)==1, sizexx(1) = []; end
--> error: "Removing elements from a matrix is not supported."
Might this even though be a practicable way of implementing ppval into an embedded matlab (eml) environment? Or is making this function eml-compatible hopeless?

2. using a c-coded function ppval (e.g. name it ppvalmex) (from here: http://octave.1599824.n4.nabble.com/ppval-td1674970.html) to have compiled a ppvalmex.mexw32 and hence I referenced this using ppvalmex() instead of ppval() or ppval_int()). But this didn't work for the reason, that "Embedded MATLAB can only compile MATLAB files; unsupported file extension 'mexw32'"
--> is there maybe a way to make use of the ppvalmex.c, as in the above source, for using it in an eml-environment? or would i necessarily need to recode this without any mxArrays but with sfunction compatibility into an sfunction block?


My questions:
a) which of those two options is in your opinion the most promising option? or might there be another better option I didn't think of yet? how could I work around my previously found obstacles?
b) is there somewhere an eml-compatible implementation of ppval, which I could easily use?
c) does building a ppval-sfunction-block even make sense, since I call the ppval-function for about 10 times in my eml-function-block?
d) consider the fact I'd have a working sfunction-ppval-block. Is there actually a possibility to transfer the pp-structures through the block-gates in Simulink?


I would really appreciate your help.
Thanks,
trabbie

Phil Goddard

unread,
Dec 7, 2011, 4:37:07 AM12/7/11
to
You don't explicitly say that you need to use this in code generation.

If not, then just define ppval as being eml.extrinsic.

If you need to it for code generation then you can either:
a) take the m-code and spend time modifying it so that it is eml compliant.
This may or may not be an easy process.
b) take the c-code that you indicate you have and convert it to a c-mex S-Function.
Again, this may be easy or may be complicated.
If you aren't familiar with S-Functions then you might be able to do it with the legacy code tools or the S-Function builder.

Phil.
0 new messages