The coder.ceval function is not supported in MATLAB.

9 vues (au cours des 30 derniers jours)
Abdul K
Abdul K le 2 Août 2020
Réponse apportée : Walter Roberson le 2 Mar 2025 à 21:52
am using the Matlab System block to create a library block , and I am getting this error when I used the coder.ceval (The coder.ceval function is not supported in MATLAB) How is iy possible to say that coder.ceval is not supported by Matlab?
Here the section of the Matlab system template that gives me the error:
methods (Access = protected)
function setupImpl(obj)
if coder.target('Rtw')% done only for code gen
% initialize the sensor
else
%
% coder.allowpcode('plain');
coder.cinclude('Pixy2Cam.h ');
coder.ceval('Pixy_setup');
end
end
This is the intitializaiton code that I want to first run:
extern "C" void Pixy_setup()
{
Pixy2 pixy;
pixy.init();
SPI.begin();
Serial.begin(9600);
}
Pixy2Cam.h:
#include "rtwtypes.h"
#ifdef __cplusplus
extern "C" {
#endif
void Pixy_setup();
float get_Pixy_Color(int IC);
float get_Pixy_x(int IC);
float get_Pixy_y(int IC);
float get_Pixy_w(int IC) ;
float get_Pixy_h(int IC) ;
#ifdef __cplusplus
}
#endif
I attached the error and the header file.
  • Pixy2CameraModel1_build_20200801_222918

Réponses (2)

Akshat Dalal
Akshat Dalal le 2 Mar 2025 à 15:45
Modifié(e) : Akshat Dalal le 2 Mar 2025 à 15:46
Hi Abdul,
The error message:
The coder.ceval function is not supported in MATLAB.
is thrown when using coder.ceval in a MATLAB script. This is because this function is only for use in scripts for code generation. You cannot run it as part of a MATLAB Script or include it in a library block. To determine if the function is used in MATLAB or for code generation, use coder.target. 
This is highlighted in the tips section of the documentation for this function: https://www.mathworks.com/help/simulink/slref/coder.ceval.html#d123e282022

Walter Roberson
Walter Roberson le 2 Mar 2025 à 21:52
To call C code from MATLAB, use loadlibrary and calllib

Produits


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by