Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How can I convert a matlab code to C?

Asked by Ijeoma Madu

Ijeoma Madu (view profile)

on 30 Jan 2013

I want to convert this to C code

function [c]= add(a,b)

c=a+b

How is the compiler used to convert this to C, i am new to this. I do not have a Matlab coder.

1 Comment

Shashank Prasanna

Shashank Prasanna (view profile)

on 30 Jan 2013

If you don't have MATLAB Coder, you will have to write it yourself. There is no other way to automatically generate C code out of MATLAB code.

Ijeoma Madu

Ijeoma Madu (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson

Walter Roberson (view profile)

on 30 Jan 2013
Accepted answer

MATLAB Coder is the only product for converting MATLAB to C.

MATLAB Compiler (a different product) does not convert to C: it converts to internal data structures that are interpreted by a MATLAB engine.

1 Comment

Ijeoma Madu

Ijeoma Madu (view profile)

on 31 Jan 2013

Thanks. I guess i would get a coder. But how is the compiler used, i would like to see its benefits. I have never used it before

Walter Roberson

Walter Roberson (view profile)

Contact us