in reply to Re^2: calling MATLAB from perl in order to create a .mat file
in thread calling MATLAB from perl in order to create a .mat file
I can say there are no immediately clear errors in the posted code, but again I have not worked with MATLAB on the command line for quite some time. You do some things I would consider quite poor form, such as not testing for the success of your open, using bareword file handles and using 2-argument open, but these are not syntax errors.
A potentially much cleaner solution is rather than piping into the executable is use your Perl script to explicitly generate a .m file, and then execute the .m using system or backticks. In this way, you will have an audit trail so you can figure out which language is giving you problems - I frequently take this autogeneration approach with auxilliary programs. Remember that Perl was originally designed for text processing and does it exceptionally well. Perhaps this will give you some ideas:
#!/usr/bin/perl use strict; use warnings; open(my $matlab, '>', 'm_file.m'); print $matlab <<EOF; x=1; save timer; EOF system('matlab -nojvm -r m_file');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: calling MATLAB from perl in order to create a .mat file
by Spooky (Beadle) on Jan 21, 2010 at 17:54 UTC | |
by kennethk (Abbot) on Jan 21, 2010 at 20:21 UTC |