when to use coder.ceval and Legacy code tool ?

9 次查看(过去 30 天)
Hello,
I am having the interface definitions in c++ files and I would like to use that interfaces in Matlab simulink. So, please suggest whether better to use coder.ceval or legacy code tool ? and how the both are different from each other.

采纳的回答

Raunak Gupta
Raunak Gupta 2019-9-30
Solution:
Hi,
The Legacy Code Tool is generally used for integrating the C or C++ function into Simulink. The functions are generally S-functions which need to be inserted as a Simulink Block in the model. Whereas using coder.ceval and other equivalent commands we can call external C/C++ functions into MATLAB environment. For this Code Generation is used while calling the C/C++ function. It is suggested to use Legacy Code Tool while working with Simulink Models and if working on Building interface between C/C++ code to MATLAB, coder.ceval can be used.
For more info about interfacing C/C++ function into MATLAB you may refer to the following:
  1 个评论
CHV
CHV 2019-9-30
编辑:CHV 2019-9-30
Hi,
Thanks for your answer.
I am using coder.ceval to call the C functions in matlab. Just I would like to know how to accesss the enum from the c functions. when I am trying to call the enum as shown below it is throwin the below error. Could you please provide me the solution for this.
Cannot assign 'a' from 'coder.ceval' because the type and size of 'a' are not known. To fix, preinitialize 'a'.
**********external c header file**********
typedef enum {
DISABLED = 0,
ENABLED = 1,
ERROR = 11,
UNDEFINED = 10,
}State;
*************Matlab function***************
function a = b
a = coder.ceval('FindState');

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 C Shared Library Integration 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by