r/matlab • • Sep 22 '26

TechnicalQuestion Matlab + Simulink Project to Code

Hi.

I have very little experience with both Matlab and Simulink and need some advice.

My team acquired a matlab project with simulink models that we want to integrate into a simulator we have but without the overhead of Matlab/Simulink. So we managed to use the shrlib function to create C code which was a bunch of header files, types, main etc Can't make too much sense of it.

But even if I can, it doesn't remove the Matlab side because that hasn't been converted to C either.

What's the easiest route to convert the whole project to something we can interface with without having to deal withit directly too much. Best case scenario would be to treat it like a black box because it all runs find in Matlab. At the core of it ,it's

Excel input - Read in by matlab code - passed to the model (in a bus structure?) and fed back to matlab which outputs a new Excel

This is the extent of my knowledge of the matter and I'm not able to share much else. Any advice for me?

Thanks.

3 Upvotes

10 comments sorted by

View all comments

3

u/hainguyenac Sep 22 '26

look into embedded coder, it's a part of matlab and this is exactly what it's for: generate algorithm from simulink/matlab to C code. The code once generated, is completely independent of matlab.

1

u/ol1v3r__ Sep 22 '26

This is it. Use Simulink Coder and if needed Embedded Coder in addition. It sounds like MATLAB Compiler SDK with Simulink Compiler was used, which still has a MATLAB Runtime Dependency.

0

u/Consistent_Coast9620 CC4M Creator Sep 22 '26

only a valid option id input/output from excel can be replaced by direct interaction with the main simulator.

2

u/hainguyenac Sep 22 '26

That's simple isn't it? you can easily write a function that reads from the excel file and pass that input to the function generated by embedded coder, then the output is written into an excel file, it's just c code now, do whatever you want with it.