running c program in matlab

조회 수: 9 (최근 30일)
Don S
Don S 2013년 12월 26일
답변: Walter Roberson 2013년 12월 27일
Hi,
I have a general doubt. I have a c program and I would like to execute the program inside the matlab using unix command.For example if the .c file is "scale.c". Then if I give unix(scale);
it always show an error "..is not recognized as an internal or external command, operable program or batch file". Kindly provide a solution for this.
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 12월 26일
Do you want to start it as an independent program? or do you want to start it as an independent program except passing in stdin and out stdout? Or do you want to call various routines in the C source as if they are commands written in MATLAB, with access to the variables ?
Don S
Don S 2013년 12월 27일
Yes , I would like to call various routines in the C source into my matlab program.

댓글을 달려면 로그인하십시오.

답변 (4개)

Image Analyst
Image Analyst 2013년 12월 26일
Can you compile it into a standalone executable and run it with the system() function?

Walter Roberson
Walter Roberson 2013년 12월 27일
To call routines in the C source, you have two choices:
  1. You can compile the C source as a library, and then loadlib() the library and call the routines; or
  2. You can create a MEX interface to the C source, compile it all with "mex", and then it can be called as if it is built-in MATLAB functionality.

The Matlab Spot
The Matlab Spot 2013년 12월 26일
I dont know if you have referred s-functions
  댓글 수: 1
The Matlab Spot
The Matlab Spot 2013년 12월 26일
편집: The Matlab Spot 2013년 12월 26일
are you trying to use the .c file in Simulink or a MATLAB program (script/function)?

댓글을 달려면 로그인하십시오.


The Matlab Spot
The Matlab Spot 2013년 12월 26일
I dont know about using unix commands, But Can you check out if you can use C-Shared Libraries instead

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by