1
votes

Before you answer, I'm not looking for the functionality of ; to suppress command line printing.

I have a set of scripts which are not mine and I do not have the ability to change. However, in my scripts I make a call to these other scripts through evalin('base', 'scriptName'). Unfortunately, these other scripts do a lot of unnecessary and ugly printing to the command window that I don't want to see. Without being able to edit these other scripts, I would like a way to suppress output to the command line for the time that these other scripts are executing.

One potential answer was to use evalc, but when I try evalc(evalin('base', 'scriptName')) MATLAB throws an error complaining that it cannot execute a script as a function. I'm hoping there's something like the ability to disable command window printing or else redirecting all output to some null file much like /dev/null in unix.

3
How are the scripts outputting to the command window? Lack of ;? disp? fprintf? Why can't you edit the scripts? - excaza
They generally use fprintf. I cannot edit the scripts because they're not mine and I don't have access to them. I can only run them. - zephyr
You could overload fprintf to do nothing, but this is not a good solution. You are better off fixing the files yourself. You'd also be much better off refactoring these scripts into functions so you pass them arguments explicitly rather than relying on evalin to function correctly. - excaza
@excaza As I said, I don't have permissions to edit the files. I can only run them. However your solution to overload fprintf, while horrible practice, is the only valid solution I can find. If you write an answer, I'll accept it. - zephyr

3 Answers

1
votes

I think you just need to turn the argument in your evalc example into a string:

evalc('evalin(''base'', ''scriptName'')');
0
votes

Have you tried this solution here ?

echo off;
0
votes

I don't know if it will fit your needs, but another solution can be to open a new session of Matlab, and use there only minimized -nodesktop form (-just the command window). You can run from there the annoying scripts, and work on the main session as usual.

The problem here is that the sessions can't be synchronized, so if you need to work with the results of the scripts all the time, it'll be a little bit complicated. Maybe you can save the result to disk, than call it from the main session... But it mainly depends on your workflow with those scripts.