Thread Subject: Converting 'C' to an 'M-file'

Subject: Converting 'C' to an 'M-file'

From: Steve C

Date: 17 Nov, 2009 17:28:20

Message: 1 of 3

After spending some time converting a 'C' program into a MATLAB script file in order to incorporate it into our suite of MATLAB based data processing routines, I am now wondering if I could run the 'C' program in MATLAB? It would need to access data created from another MATLAB script stored locally. I thought translating it into MATLAB would improve it's efficiency as it would be running on MATLAB, but having read something about 'MEX-files' I am becoming uncertain. Any quick-start guide to running 'C' programs as M-file scripts would be most helpful.

Subject: Converting 'C' to an 'M-file'

From: Wayne King

Date: 17 Nov, 2009 17:45:24

Message: 2 of 3

"Steve C" <stephen.cutler@baesystems.com> wrote in message <hdumfk$46t$1@fred.mathworks.com>...
> After spending some time converting a 'C' program into a MATLAB script file in order to incorporate it into our suite of MATLAB based data processing routines, I am now wondering if I could run the 'C' program in MATLAB? It would need to access data created from another MATLAB script stored locally. I thought translating it into MATLAB would improve it's efficiency as it would be running on MATLAB, but having read something about 'MEX-files' I am becoming uncertain. Any quick-start guide to running 'C' programs as M-file scripts would be most helpful.

Hi Steve,

see

>>doc mex

and also in the Matlab User Guide -> External Interfaces -> Creating C/C++ Language MEX-files

wayne

Subject: Converting 'C' to an 'M-file'

From: Steve C

Date: 25 Nov, 2009 10:27:04

Message: 3 of 3

"Wayne King" <wmkingty@gmail.com> wrote in message <hdunfk$6kg$1@fred.mathworks.com>...
> "Steve C" <stephen.cutler@baesystems.com> wrote in message <hdumfk$46t$1@fred.mathworks.com>...
> > After spending some time converting a 'C' program into a MATLAB script file in order to incorporate it into our suite of MATLAB based data processing routines, I am now wondering if I could run the 'C' program in MATLAB? It would need to access data created from another MATLAB script stored locally. I thought translating it into MATLAB would improve it's efficiency as it would be running on MATLAB, but having read something about 'MEX-files' I am becoming uncertain. Any quick-start guide to running 'C' programs as M-file scripts would be most helpful.
>
> Hi Steve,
>
> see
>
> >>doc mex
>
> and also in the Matlab User Guide -> External Interfaces -> Creating C/C++ Language MEX-files
>
> wayne

Wayne,

Thanks for taking the time out to reply to my query, I have had a look at 'doc mex' and 'Creating C/C++ Language MEX-files' and attempted to implement them into my program.
However, there is mention of using 'mexfunction' instead of 'main()' in my 'C' program, so do I just overwrite the text 'main(vars)' with 'mexfunction' thus renaming the main function? Or, is it a case of copy-and-pasting the main function to the end of the file and calling it mexfunction. The intricacies of the help files for those of us who are definitely more beginner than intermediate is where they are let down.

Regards

Steve

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
c program Steve C 17 Nov, 2009 12:29:20
rssFeed for this Thread

Contact us at files@mathworks.com