Modifying and compiling c code within MATLAB function

Just a note in advance, my experience with coding in C is very limited so what I am looking to do may be impossible.
Currently, I have a C source file that does a lot of calculations for me, along with a header file that contains constants used by the source file. I am attempting to use MATLAB to iteratively change how the source file performs the calculations and to change the constants within the header file.
I am able to read in the source file and the header file, modify the calculations and constants, and save the new source file and header file to my current directory. However, I am assuming that after modifying the source file and header file I must then recompile the source file before I can use it.
Are there currently any functions or tools within MATLAB that would allow me to do this?
Thanks in advance for any help or feedback you can provide.

5 件のコメント

dpb
dpb 2014 年 4 月 29 日
You can dispatch the compiler/linker to the OS via "!" (the bang! operator) or system
I'd ask why don't you rewrite the function to accept these various constants as inputs and remove the need, though?
Michael
Michael 2014 年 4 月 30 日
Thanks for the idea. I had thought of doing that, but like I said my experience with coding in C is very limited. Previously, I was manually changing the constants, recompiling the code, and running it. I'm attempting to automate that process so my first attempt at it was to just replace those steps with matlab code.
Harsheel
Harsheel 2014 年 4 月 30 日
However, I am assuming that after modifying the source file and header file I must then recompile the source file before I can use it.
How are you actually "using" it, are you creating an executable, a shared library?
James Tursa
James Tursa 2014 年 4 月 30 日
Are you creating an exe or a mex routine?
José-Luis
José-Luis 2014 年 4 月 30 日
So you are basically using Matlab as a text editor. That sounds like overkill, I'm afraid. Is there any particular reason you are doing so?

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Compiler についてさらに検索

質問済み:

2014 年 4 月 29 日

コメント済み:

2014 年 4 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by