I'm running some code remotely on Matlab on Unix that generates many plots. I don't want hundreds of figures to pop up on my local system. (And I suspect that the windowing process slows down the execution of my code too.) I read that setting the DISPLAY environment variable to null restricts this behavior, and indeed,
$export DISPLAY=
$matlab14a -nodisplay -nosplash
>>X=1:10;
>>Y=X.^2;
>>plot(X,Y);
Immediately returns the cursor to the console and does not display the plot. However, then I want to be able to toggle the display back on. I can run
>>setenv('DISPLAY',':1102') %Previous (correct) value of $DISPLAY
>>getenv('DISPLAY')
ans =
:1102
>>plot(X,Y);
However, the plot still does not appear. I believe that this occurs because my system routes the matlab instance through the qrsh scheduler and then another subshell. So when I change my DISPLAY variable, I believe that whichever shell is not accessing this variable. I don't know the exact details of this process.
My question is, how can I get Matlab to correctly display plots once I have changed the DISPLAY variable to the correct value? Alternately, are there any other solutions for toggling the display of all plots/figures?
disp( X ) displays the value of variable X without printing the variable name. Another way to display a variable is to type its name, which displays a leading “ X = ” before the value. If a variable contains an empty array, disp returns without displaying anything.
You can edit the value of a variable element by clicking the element and typing a new value. Press Enter or click another element to save the change.
To display a text in MATLAB, we use 'disp function' which displays the text or value stored in a variable without actually printing the name of the variable.
MATLAB Variable. After reading this MATLAB Variable topic, you will understand how to create and manipulate Variable, and you will understand how to assign and display variable data in MATLAB. In MATLAB, an assignment statement automatically generates variable. An assignment statement used for assigning a value to a variable.
In MATLAB, an assignment statement automatically generates variable. An assignment statement used for assigning a value to a variable. The assignment statement generally having the symbol = which is known as the assignment operator. x is variable. 10 is the value assigned to variable x.
In MATLB, fprintf statement is used to print a variable data. x is variable. = is the assignment operator. fprintf (‘The x is %d ’,x) statement to display variable x value.
Variable name length limits up to 63 characters long. A variable name can be made with letters, digits, and the underscore character. Punctuation characters (e.g., period, comma, semicolon) are not allowed for defining variable names. MATLAB is case sensitive: it discriminates between uppercase and lowercase letters.
I think that running maltab with -nodisplay
flag makes it ignore completely all figures and I do not think you can recover from that by changing the DISPLAY
environment variable.
What you can do is setting the default 'visible'
property to 'off'
set( 0, 'DefaultFigureVisible', 'off');
Before your code starts to run and only turn 'visible'
to 'on'
for the figures you really want to see. Or, resetting the default value to 'on'
once you are done with the main computation part of your program.
set( 0, 'DefaultFigureVisible', 'on');
See here for more info about setting default values for properties.
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