How do I include a header file in MATLAB code?
29 views (last 30 days)
Show older comments
I'm quite new to MATLAB and I'm trying to make a header file and include it in my MATLAB code. The header file contains a lot of constants and calculations that would be needed in the main code. I'm not sure first of all though how to save the header file, (should it be .m?) and also what's the line of code needed to include it in a MATLAB code. I'm only getting answers for including C/C++ header files in MATLAB. Apologies if this is a really basic question!
0 Comments
Accepted Answer
More Answers (1)
thayalan thayalan
on 9 Dec 2021
During mex build the following error observed , how to solve this error ?

3 Comments
thayalan thayalan
on 9 Dec 2021
#define that defines the uint8_T should be there with Matlab compiler and also "C" extension should not create an issue.. I am misssing somthing about compiler but i can't able to find it out.
dpb
on 9 Dec 2021
Edited: dpb
on 9 Dec 2021
Still looks to me like the preprocessor isn't being called...I don't write much C at all and am just beginning to play with gcc the last few days, so I'm still pretty raw. I am almost exclusively Fortran and there the preprocessor isn't automagically invoked if the source input file name doesn't begin with an uppercase "F" -- but the C compiler should call it anyway -- altho I do see the doc says does need the extension.
I'd try the "-E" option to force the preprocessor to run and echo the preprocssed file output to see what it actually sees and if that resolves the missing macro.
Would have to see the full source file to be able to diagnose anything further...
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!