Reading constants and variables from external header files in Matlab Coder
조회 수: 9 (최근 30일)
이전 댓글 표시
If I have the C header file external_vars.h containing:
const int ext_var = 5;
How do I use it in a Matlab Coder generated C function? The following code doesn't work, as ext_var is not defined in the Matlab code.
function external_test() %#codegen
coder.cinclude('external_vars.h')
a = ext_var;
end
댓글 수: 0
채택된 답변
Denis Gurchenkov
2019년 5월 2일
If you have an Embedded Coder license, you can use coder.storageclass to bind an extern C variable to a variable in MATLAB function: https://www.mathworks.com/help/ecoder/ref/coder.storageclass.html?s_tid=doc_ta
Without Embedded Coder, one possible workaround is to have a C function that reads/writes to this variable, and call that C function using coder.ceval.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!