Inserting C Code in Simulink block
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Alberto Prudhomme
il 14 Apr 2016
Commentato: Alberto Prudhomme
il 16 Apr 2016
Hello;
I'm trying to learn how to insert C code in the user defined blocks of simulink, but I didn't have success.
I made this code in Code Composer Studio:
#include <stdio.h>
#include <math.h>
double y;
double u;
int main(void)
{
y=u*2;
return(y);
}
And I made this simple diagram
With this code in the matlab coder:
function y = callingmultiplicador(u)
%#codegen
y = 0.0;
y = coder.ceval('multiplicador',u);
But When i try to run, i obtain this error:
Warning c2_untitled.c: 180 missing prototype for multiplicador
Warning c2_untitled.c: 180 Missing prototype for 'multiplicador'
0 errors, 2 warnings
c2_untitled.obj .text: undefined reference to 'multiplicador'
"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\bin\lcc64.exe" -dll -noregistrylookup -c -Zp8 -DLCC_WIN64 -DMATLAB_MEX_FILE -DMX_COMPAT_32 -nodeclspec -I"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\include64" -I"C:\Program Files\MATLAB\R2016a\extern\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2016a\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2016a\rtw\c\src" -I"C:\Users\Alberto\Desktop\slprj\_sfprj\untitled\_self\sfun\src" -I"C:\Users\Alberto\Desktop" "untitled_sfun.c"
"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\bin\lcc64.exe" -dll -noregistrylookup -c -Zp8 -DLCC_WIN64 -DMATLAB_MEX_FILE -DMX_COMPAT_32 -nodeclspec -I"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\include64" -I"C:\Program Files\MATLAB\R2016a\extern\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2016a\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2016a\rtw\c\src" -I"C:\Users\Alberto\Desktop\slprj\_sfprj\untitled\_self\sfun\src" -I"C:\Users\Alberto\Desktop" "c2_untitled.c"
"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\bin\lcc64.exe" -dll -noregistrylookup -c -Zp8 -DLCC_WIN64 -DMATLAB_MEX_FILE -DMX_COMPAT_32 -nodeclspec -I"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\include64" -I"C:\Program Files\MATLAB\R2016a\extern\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2016a\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2016a\rtw\c\src" -I"C:\Users\Alberto\Desktop\slprj\_sfprj\untitled\_self\sfun\src" -I"C:\Users\Alberto\Desktop" "untitled_sfun_registry.c"
"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\bin\lcc64.exe" -dll -noregistrylookup -c -Zp8 -DLCC_WIN64 -DMATLAB_MEX_FILE -DMX_COMPAT_32 -nodeclspec -I"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\include64" -I"C:\Program Files\MATLAB\R2016a\extern\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2016a\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2016a\rtw\c\src" -I"C:\Users\Alberto\Desktop\slprj\_sfprj\untitled\_self\sfun\src" -I"C:\Users\Alberto\Desktop" "C:\Users\Alberto\Desktop\multiplicador.c"
"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\bin\lcc64.exe" -dll -noregistrylookup -c -Zp8 -DLCC_WIN64 -DMATLAB_MEX_FILE -DMX_COMPAT_32 -nodeclspec -I"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\include64" -I"C:\Program Files\MATLAB\R2016a\extern\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include" -I"C:\Program Files\MATLAB\R2016a\simulink\include\sf_runtime" -I"C:\Program Files\MATLAB\R2016a\stateflow\c\mex\include" -I"C:\Program Files\MATLAB\R2016a\rtw\c\src" -I"C:\Users\Alberto\Desktop\slprj\_sfprj\untitled\_self\sfun\src" -I"C:\Users\Alberto\Desktop" "C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\mex\lccstub.c"
"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\bin\lcclnk64.exe" -s -dll -L"C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\lib64" -entry LibMain -map sfun.map -o untitled_sfun.mexw64 @untitled_sfun.lmko
C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\bin\lccmake.exe: Error code 1
C:\Program Files\MATLAB\R2016a\sys\lcc64\lcc64\bin\lccmake.exe: 'untitled_sfun.mexw64' removed.
Component: Make | Category: Make error
Unable to create mex function 'untitled_sfun.mexw64' required for simulation.
Can you help to understand the problem???
Thanks
Regards
0 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!