MATLAB Answers

how run .c program in matlab

442 views (last 30 days)
manoj saini
manoj saini on 29 Jan 2013
Commented: LeChat on 14 May 2020 at 19:49
if i have program print.c
how i can run this code in MATLAB


Sign in to comment.

Accepted Answer

Shashank Prasanna
Shashank Prasanna on 29 Jan 2013
If you want to call your C function from within MATLAB you have to create a MEX file. Which mean you will have to modify your C code with the following guidelines:


Show 4 older comments
LeChat on 17 Apr 2020
indeed the links do not work anymore...
LeChat on 14 May 2020 at 19:49
thank you Walter

Sign in to comment.

More Answers (1)

syracus syr
syracus syr on 1 Feb 2018
@Shashank Prasanna I don't understand your explanation, how can I create this bat file. What should I put (code) in the file? For example, I have a "execute.bat" file. What should this file contain? Thank you so much!


Walter Roberson
Walter Roberson on 1 Feb 2018
? I do not see any obvious reference to bat files in the links Shashank Prasanna posted?
syracus syr
syracus syr on 2 Feb 2018
Hi, @Walter Roberson, I want to call C function from within MATLAB with MEX file. I wrote here because I did not know the difference between MEX and BAT files. I've seen this title while researching c language with Matlab. Thank you!
Walter Roberson
Walter Roberson on 2 Feb 2018
mex files are DLL files with a different file extension, and which define a special function named mexFunction.
If you have an existing DLL then you can use loadlibrary() instead of building a mex interface to the C code.

Sign in to comment.

Sign in to answer this question.

Translated by