Issues with integrating custom C Code in Simulink

조회 수: 2 (최근 30일)
Sanat
Sanat 2013년 12월 6일
Sorry if there's a similar question already, I wasn't able to find one all morning. I am trying to integrate a custom code snippet into Simulink. I followed the instructions in the documentation as follows (I understand this problem could be due to my lack of mad C programming skills but I'd really appreciate it if someone would point me in the right direction.)
//custom header file saved as mycustomcode.h
extern double mycustomecode(double , double );
//custom c code file containing the function definition saved as mycustomcode.c
#include "mycustomcode.h"
double mycustomecode(double inval, double constval){
double outval;
outval = inval + constval;
return outval;
}
In my Stateflow Chart I have a default transition where I have the function call :
{SF_Out = mycustomcode(SF_In,constant_1);}
The Output variable and the two input variables, I have defined in the model explorer.
From within the SF Chart I go Tools>Open Simulation Target > Simulation Target > Custom code and under Include Custom C Code in generated : Header file :
#include "mycustomcode.h"
and under Include list of additional : source files :
mycustomcode.c
I try to Build or Update Diagram but get the following problems :
c4_test_log_in_sf.c(182) : warning C4013: 'mycustomcode' undefined; assuming extern returning int
and upon linking :
c4_test_log_in_sf.obj : error LNK2019: unresolved external symbol _mycustomcode referenced in function _sf_c4_test_log_in_sf test_log_in_sf_sfun.mexw32 : fatal error LNK1120: 1 unresolved externals NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\link.exe"' : return code '0x460' Stop.
Someone please help me :)

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by