guilhermecgs
guilhermecgs

Reputation: 3041

Matlab Coder - Generating EXE from .m file

My main goal is to integrate a code written in matlab(.m) with another c# application. I have considered 2 options:

  1. Use Matlab Builder NE
    • Pros: Use to use!
    • Cons: Need a license ($$) that I dont have so far. Needs MCR installed on end-user PC.
  2. Generate a standalone EXE file from a .m file
    • Pros: Dont need anything to run.
    • Cons: Hard for a newbie to use. Do not support all functions.

So far, I am trying to make a "proof of concept" of option 2), but with no success. I don't even know how to start my question; I will improve my question as soon I get to know the toolboxes a little bit more. Please inform me if the question does not meet the standards.

  1. What is the relationship between Matlab Coder, Real-Time Workshop(RTW) and RTW Embedded Coder? I am sure I have both RTW licences, but I am not sure I have "Matlab Coder"
  2. I am trying to use "emlc" command to generate the EXE. Is it the right command? I couldn't manage to get it working. I generated the C/C++ code correctly, but the EXE is not generated (I have already configured the MEX setup)
  3. The C/C++ code generated by "emlc" can be imported in Visual Studio in order to compile and build the EXE? Is it super-easy?
  4. "Emlc" belongs to which toolbox?
  5. What does %#codegen directive stands for?
  6. Imagine that I have 2 functions (functionA, functionB) in a .m file. Imagine also that I was able to generate the EXE. What would be be entry point for the exe? Would it be functionA or functionB? How can I define the data type?

Upvotes: 1

Views: 1308

Answers (2)

sebastian
sebastian

Reputation: 9696

Referring to 6):

The entry point would be the same as it is in MATLAB - hence, the first function defined in the m-file. Command-line arguments will all be passed as strings to this function.

Upvotes: 2

am304
am304

Reputation: 13876

MATLAB Coder is a relatively new product that allows you to generate C code from MATLAB, without having Simulink. Before that, you needed Simulink and Real-Time Workshop (even if you were not using Simulink) to generate C code from MATLAB using emlc. When MATLAB Coder was released, Real-Time Workshop was renamed to Simulink Coder, and Real-Time Workshop Embedded Coder to Embedded Coder. The difference between MATLAB/Simulink Coder and Embedded Coder is that the "basic" coder products allow to generate functionally correct code, but that code is not optimised for real-time performance or customisable to meet certain coding standards. Embedded Coder allows you to optimise and customise the code generate by MATLAB and Simulink Coder. If you had a license for RTW, then you would have been given a free license of MATLAB Coder when it was release as MATLAB Coder is a pre-requisite for Simulink Coder.

I believe emlc belongs to MATLAB Coder. The code generated by MATLAB Coder can be imported and compiled in Visual Studio. I don't know how easy it actually is, but there is a functionality called "Pack N Go" supposed to make this process easier, check it out. There is also a Visual Studio target, but not sure whether this is in base MATLAB Coder or whether you also need Embedded Coder.

Upvotes: 3

Related Questions