# Guy and Seth on Simulink

## Welcome to the Coders!

By Guy Rouleau

Did you already install MATLAB R2011a?

If you are used to generating code from Simulink, the first thing you probably thought after launching MATLAB R2011a is: "Where is Real-Time Workshop?"

Don't panic, this is normal! All good things have an end; it is now time to say goodbye Real-Time Workshop, and welcome Simulink Coder. I officially proclaim: Le Roi est mort, vive le Roi!

Consolidation of Code Generation Products

Before introducing the cool new Simulink R2011a features, I want to describe a significant reorganization of the code generation products. Since an image is worth a thousand words, here is what happened:

Let's describe how features are divided among these three products:

MATLAB Coder

Traditionally, MathWorks code generation products have all been centered around Simulink. However in the last few years we've received more and more requests to generate code for prototyping and embedded processors directly from MATLAB code. It is difficult to admit for a Simulink fan like me, but it is true that some algorithms are easier to implement in MATLAB code than using blocks. This is particularly the case for many algorithms in digital signal processing and communications systems.

In addition to all the Embedded MATLAB features previously included with Real-Time Workshop, MATLAB Coder includes some cool new stuff, for example the coder function to start a MATLAB Coder Project using a graphical interface:

Simulink Coder combines the previous functionality of Real-time Workshop and Stateflow Coder. This means one single product to generate code for all Simulink multidomain models, regardless of which add-on products are used to create those models.

Embedded Coder

The Embedded Coder consolidates all MathWorks code generation tools for embedded system development into a single product:

• The previous features of Real-Time Workshop Embedded Coder for generating production embedded code.
• Processor and board specific customization previously included with Target Support Package.
• Tools to integrate popular embedded toolchains previously included with Embedded IDE Link.

Are you going to take advantage of the new MATLAB Coder? Let us know how by leaving a comment here.

### 9 Responses to “Welcome to the Coders!”

1. Allan Baker replied on :

Hopefully all of these have been thoroughly tested with 64-bit distributed cluster machines (Simulink accelerator and embedded matlab mex) and also using embedded Matlab cstructname with externally defined header files (mex and code-gen). Been having awful luck with upgrades lately.

Does this upgrade change the TLC files tremendously from 2010B to 2011A?

2. Thomas Marullo replied on :

I use Simulink with RTW and xPC Target to create real-time systems. I also use the Matlab Embedded Simulink blocks to write custom code within my Simulink models. I see that with newer versions, RTW is now Simulink Coder. Do I also have to puchase Matlab Coder in order to get the Matlab Embedded Code blocks in Simulink?

*confused*

3. tom erkkinen replied on :

Hi Thomas – Simulink Coder now requires MATLAB Coder, just like Simulink requires MATLAB, so yes you need MATLAB Coder to use Simulink Coder.

If you subscribe to MathWorks Software Maintenance Service (SMS) and update to 11a, then you will automatically get MATLAB Coder with Simulink Coder (for the RTW transition) and don’t need to purchase MATLAB Coder separately.

I’m curious – What type of code/logic do you write with the MATLAB block?

4. tom erkkinen replied on :

Hi Allan,

The migration from RTW to Simulink Coder should be smooth. I’ve had several customers and embedded target partners report quick migration even during beta usage. Check out our release notes for version compatiblity topics (e.g, the ver command had a slight change). But let us know if you have issues.

5. Thomas Marullo replied on :

Hi Tom,
Thanks for the info. I use Embedded Matlab Function blocks, or now Matlab Function blocks to take Matlab code we use for Finite Element analysis and use it in xPC Target. It is very difficult to convert those 100s of lines of code into Simulink code so the Matlab Function blocks are useful for porting M files into Simulink.

6. Hans Hoelzer replied on :

Seems like we have come full circle (or mostly so). Was there not a product in the past called the Matlab compiler (not to be confused with the current Matlab compiler which is actually a wrapper generator and Matlab interpreter em bedder) which translated Matlabese into C code? As I recall there was also a math library and a graphics library. How does the current offering differ from that one?

7. Seth Popinchalk replied on :

@Hans Hoelzer – You are right, the old MATLAB Compiler technology did not rely on the MATLAB Common Run-time (MCR) and did generate C/C++ code. That older incarnation of the compiler also relied on MATH and Graphics libraries that contained most of the core MATLAB functionality.

The MATLAB Coder technology is very different from that old MATLAB Compiler. The MATLAB Coder is focused on generating readable C/C++ code from a subset of the MATLAB language, and does not rely on libraries. I think it will be most used by people developing algorithms that need to be deployed to embedded systems, or integrated into larger applications. For desktop application deployment, the MATLAB Compiler and builder products will still provide a better path that supports the full MATLAB language.

I reccomend watching the overview video on the MATLAB Coder product page.

8. luhur replied on :

Hi guy…

as we know in real-time windows target they don’t support winAPI 32 to handle real-time, right??? what about the NEW ERA of RTWT aka SIMULINK CODER in MATLAB 2011a??? cause i’m trying to wrap my C program in simulink using legacy code tool and then run it on real-time condition.. any suggestion or info about that???

9. Guy Rouleau replied on :

@Luhur: Unfortunately, the change to Simulink Coder does not affect the fact that RTWT is incompatible with Win32 API calls, as documented here:

http://www.mathworks.com/help/toolbox/rtwin/ug/f7929.html

 Name (required) E-mail (required, will not be published) Website (optional) Spam protection (required): What is 5 + 8 ?

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>


If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).

Guy Rouleau and Seth Popinchalk are Application Engineers for MathWorks. They write here about Simulink and other MathWorks tools used in Model-Based Design.

These postings are the author's and don't necessarily represent the opinions of MathWorks.