is it possible to convert C-Code to M-file? plz. help me !

4 views (last 30 days)
hello? everyone. I have a qustion. please help me
actually, I have a lot of useful C-codes in my computer
I heard that it is possible to convert M-file to C-code by using the some fuction.
then , this is my question that the other way, is it possible to convert C-Code to M-file? i want to see the M-file converted from C-code
if there is no way to convert it , please tell me the best way to see the M-file converted form C-code.

Answers (2)

Jan
Jan on 8 Aug 2013
Edited: Jan on 8 Aug 2013
When reading the M-code converted from a C-code is the main point, this has a strong bias: You will not see a 1-by-1 conversion of the C-code in the best case, but the converter itself has to inject some parts and knowledge for the conversion already, such that the created M-code will significantly depend on the used converter.
The same effect happens, when you try to translate a haiku to another language. Either the resulting poem is a perfect translation and looses all its power, or the result is powerful and beautiful, but has no direct relation to the original anymore.
There is a substantial difference between studying algorithms and implementations in different languages.
  1 Comment
Mike Hosea
Mike Hosea on 9 Aug 2013
Edited: Mike Hosea on 9 Aug 2013
+1
It is a lot to ask for an automatic translator to produce MATLAB code of sufficient quality that one will get a sense of how things ought to be done in MATLAB. In fact I do not know of a C to MATLAB translator, but if there is one, I think we can be fairly certain the MATLAB code will end up looking a lot like C code and nothing like how an expert MATLAB programmer would have written it.

Sign in to comment.


Matt J
Matt J on 8 Aug 2013
Edited: Matt J on 8 Aug 2013
I don't think there is a way to do that, but it's hard to see why someone would want to. You can run C-code from MATLAB by calling it from a MEX file.
  3 Comments
Walter Roberson
Walter Roberson on 10 Aug 2013
mex files have C (or C++ or Fortran) source code that you can read (provided the source was provided; if it was not then you have a problem anyhow.)
Matt J
Matt J on 10 Aug 2013
Edited: Matt J on 10 Aug 2013
I don't need some result datas , just I want to see the M-files converted from C-code
@Jin,
Others have made similar remarks but in case it isn't clear, the translation from C-code to M-code is not unique. There are M-code re-implementations that would optimize speed and others that would optimize memory usage, and many others in between. Even if there was a tool that could produce one of the many possible translations, you wouldn't be able to draw any general conclusions from it.

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!