Legendre
Legendre

Reputation: 3156

Running C program's executable from Matlab and getting the output

I compiled a C program in Visual Studio Express 2010.

#include<stdio.h>

main()
{
    printf("Hello World");

}

This produces a file "hello.exe" on my C drive. In Matlab, I use this command,

! hello

And it prints "Hello World" to my Matlab console.

What is the name of the ! Matlab command? I have been trying to find documentation for it but is having difficulty because I don't know what keywords to Google for. Thanks!

Additional Info

I will be running a fairly complicated C program that outputs a plain text file. Then using Matlab to read the text file, put the data into matrices/arrays and manipulate these in Matlab.

Upvotes: 1

Views: 3620

Answers (3)

Huguenot
Huguenot

Reputation: 2447

As a follow up point. If you are spending a lot of time writing C utility functions that you would like to use in MATLAB, you should consider turning them into MEX functions. A MEX function is a MATLAB function that uses C/C++/Fortran code in the background, allowing you to save the output of those external functions directly into your MATLAB workspace.

For more information, you can read through this: http://www.mathworks.com/help/matlab/create-mex-files.html

Upvotes: 1

Stewie Griffin
Stewie Griffin

Reputation: 14939

Have you read this?

http://www.mathworks.se/help/symbolic/mupad_ref/system.html

I think it's what you're looking for =)

Edit:

Also, if you type:

help !

You will get the name (amongst other stuff):

punct - Invoke operating system command - ! 

Upvotes: 1

eduffy
eduffy

Reputation: 40224

Try the dos command. It'll let you capture the output of other executables.

Upvotes: 0

Related Questions