C Code For Matlab Developers

April 22, 2011
The Mathworks now provides Matlab Coder to generate C and C++ code from Matlab applications. This code can be incorporated into C and C++ applications.

Matlab/C design flow

Mathworks has split its C and C++ code generation tools into three applications. They include Matlab Coder, Simulink Coder and Embedded Coder. These allow source code to be incorporated into C and C++ applications. Prior to this split, developers using Mathworks tools needed to turn to the Real Time Embedded tools to generate C or C++ code. Now Matlab and Simulink developers only need one additional tool to generate C and C++ code (Fig. 1).

The changes are significant because Matlab and Simulink are often used to develop or prototype applications that will be deployed using C or C++. Hand translation is one way to do this but it is tedious and error prone. It is also a pain to keep the C and C++ code in synch with the Matlab or Simulink code.

The three new tools eliminate a significant chunk of the work of maintaining a C/C++ application that utilizes algorithms developed using Matlab or Simulink. They essentially operate in the same fashion with slighly different starting points and they are complementary since Matlab code can be embedded in Simulink models. The embedded tool is essentially an updated version of the original C/C++ code generation support in the Real-Time Workshop Embedded Coder. It provides more advanced capabilities and requires Matlab Coder and/or Simulink Coder. It allows the user to adjust the look and feel of generated code including coding style as well as function library support. Embedded Coder provides a greater degree of control than Simulink and Matlab Coder at this time.

Matlab Coder features integration with Microsoft's Visual Studio. The tool makes it easy to find find Matlab code from the C/C++ code report.

The C/C++ tends to be 2x to 10x faster than corresponding Matlab code or Simulink models. The tools do not support all features in Matlab. Functional areas not supported include features like GUI interface support. The tools do support over 400 Matlab operators and funtions. In addition over 200 system objects like DSP algorithms are supported as well.

Addressing restricted functionality may mean refactoring a Matlab or Simulink application to move supported functionality into its own set of files. This can make debugging easier. The generated code is license and royalty free but resulting products cannot compete with Mathwords as is the case with regular Matlab applications.

Developers can select C or C++ code generation. The codegen command provides command line or make file support. Matlab Coder users will now only require a Matlab license to generate C/C++ code. The Realtime Workshop support still requires a Simulink license since it handles Matlab and Simulink code.

Pricing for Matlab Coder start at $6,500.

Sponsored Recommendations

What are the Important Considerations when Assessing Cobot Safety?

April 16, 2024
A review of the requirements of ISO/TS 15066 and how they fit in with ISO 10218-1 and 10218-2 a consideration the complexities of collaboration.

Wire & Cable Cutting Digi-Spool® Service

April 16, 2024
Explore DigiKey’s Digi-Spool® professional cutting service for efficient and precise wire and cable management. Custom-cut to your exact specifications for a variety of cable ...

DigiKey Factory Tomorrow Season 3: Sustainable Manufacturing

April 16, 2024
Industry 4.0 is helping manufacturers develop and integrate technologies such as AI, edge computing and connectivity for the factories of tomorrow. Learn more at DigiKey today...

Connectivity – The Backbone of Sustainable Automation

April 16, 2024
Advanced interfaces for signals, data, and electrical power are essential. They help save resources and costs when networking production equipment.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!