1

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?
2
  • if you want to generate an exe from Matlab, the exe will need the MATLAB runtime, that is what should you look into Commented Oct 10, 2013 at 13:35
  • 1
    @Matt only if you use MATLAB Compiler, not MATLAB Coder Commented Oct 10, 2013 at 15:07

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.