I have matlab function that calls a Perl script which converts a large text file to binary for use in Matlab. See here for Perl script details: Parsing unsorted data from large fixed width text
My Matlab function looks something like this
function convertMyData(dataFileName)
%Do some checks on the data
disp('Done Checking Stuff!');
%Process data file with Perl
perl('myPerlScript.pl',dataFileName)
% More Processing on the Binary output from Perl
disp('All Done!');
In the perl script are some print statements showing the progress of the script since it can take several minutes to convert. Something like this:
while ($line = <INFILE>) {
if ($lineCount % 100000 == 0){ #Display Progress every 100,000 lines
print "On Line: ".$lineCount."\n";
}
#PROCESS LINE DATA HERE
$lineCount ++;
} # END WHILE <INFILE>
print "Finished Reading: ".$lineCount." Lines\n";
The problem is that in Matlab all of my "On Line: XXXXX" print
statements just get dumped to Matlab's default ans
variable once the script completes instead of actually displayed at the prompt like Matlab's disp()
function.
So how (if possible) do you get an external program's output to show up at the Matlab prompt while it is running?