I am running MATLAB with a command line string like this:
C:\<a long path here>\matlab.exe -nodisplay -nosplash -nodesktop -r "run('C:\<a long path here>\mfile.m');"
The m-file contains a plot()
function to plot a simple curve on the x-y plane.
The m-file successfully runs and draws the plotting with the command line string I specified above. However, every time I run this command, a window named "MATLAB Command Window" appears along with the plotting.
How do I make this "MATLAB Command Window" NOT appear, so that only the plotting will be visible.
The "MATLAB Command Window" looks like below:
1) To disable the display of any figure windows you can use the MATLAB startup option "-noFigureWindows".
Description. clc clears all the text from the Command Window, resulting in a clear screen.
On the Home tab, in the Environment section, click Preferences. Select MATLAB > Command Window, and then adjust the options as described in this table.
If you are a running Matlab from another program on Windows, you can run it using the Matlab COM Automation Server. The ActiveX control has a Visible property which will let you make the command window invisible, but looks like it leaves the plots visible.
Here's an example of how to do it using another Matlab as the controller.
ml = actxserver('Matlab.Application');
ml.Visible = false;
ml.Execute('surf(peaks)');
Or in VBScript.
Set ml = CreateObject("Matlab.Application")
ml.Visible = false
ml.Execute("surf(peaks)")
ml.Execute("pause(4)")
This interaction mode might be more what you want anyway, depending on how your workflow is structured, because it'll let you fire up the Matlab process once and make many plot requests on it, saving startup costs and letting you have multiple plots visible at once.
If you still want to call it from a command line, just run it through a .vbs wrapper script with the above VBScript code, but call run('...\mfile.m')
instead of surf(peaks)
. Your mfile.m will need some GUI logic that makes it block until the user dismisses the plot, replacing the pause
call, so it doesn't disappear before they're done viewing it.
Great news!
With a bit of Java manipulation, it is possible! Start MATLAB normally (with the desktop etc.) Now run setDesktopVisibility(false) and voila! E.g.
setDesktopVisibility(false);
mesh(rand(10));
pause;
setDesktopVisibility(true);
AFAIK you can't do it on Windows using the options with matlab.exe
. If you really need to hide it, I'd recommend using the MATLAB Engine to display your figure. Additionally, if it's for simple things like plotting, etc. you could use GNU Octave which works with M files and does not have a "Command Window" like MATLAB does (it runs in the Windows Command Prompt and hiding it is not that hard).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With