Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling MATLAB from Perl...

Status
Not open for further replies.

jmg498

Technical User
Oct 31, 2007
26
US
I've written a MATLAB script that plots data based on ASCII data files that are written out by a program I wrote in Perl. But I have to keep copying and pasting the filename of the datafiles in order to have the MATLAB script call it.

I'm wondering if anyone knows of a way that I can call a MATLAB script from within Perl, and pass into it the filename, instead of having to do this manually?

Thanks...
 
Well.. I have no idea what Matlab is..
but you can make system calls using
qx or backticks..
`/path/to/program $dir/$file` for example.

If the script is more interactive you can use expect.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
MATLAB is a numerical computing software package, somewhat similar to Mathematica, Octave, MiniTab, etc. For scripting, it uses a syntax similar to C. I'm attempting to use it over the standard plotters (like XMGrace) because of its statistical abilities.

Essentially, in the MATLAB script I am specifying the location of a single data file. What I'd like to do is have Perl pass the filenames in on each successful run, and then have the MATLAB code execute based on the files that the Perl program sent it.

But your method gives me a few ideas. I could tell MATLAB the directory that all the datafiles will exist in, call it from Perl, and see if there's a way to script it in MATLAB to run the routine for all datafiles in that directory.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top