Change DISPLAY variable from inside Matlab

I run some code remotely on Matlab on Unix, which generates many graphs. I do not want hundreds of my shapes appearing on my local system. (And I suspect that the window slowdown process also slows down the execution of my code.) I read that setting the DISPLAY environment variable to null limits 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 a graph. However, I want to turn on the display again. 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 this is because my system routes the matlab instance through the qrsh scheduler and then another subshell. Therefore, when I change my DISPLAY variable, I believe that some shell does not have access to this variable. I do not know the exact details of this process.

My question is: how can I get Matlab to display graphs correctly as soon as I change the DISPLAY variable to the correct value? Alternatively, are there other solutions to switch the display of all graphs / numbers?

+6
source share
2 answers

I think running maltab with the -nodisplay flag causes it to completely ignore all shapes, and I don't think you can restore it by changing the DISPLAY environment variable.

What you can do is set the default property 'visible' to 'off'

 set( 0, 'DefaultFigureVisible', 'off'); 

Before your code starts working and only 'visible' to 'on' will only be displayed for the numbers that you really want to see. Or, resetting the default value to 'on' as soon as you are done with the main computing part of your program.

 set( 0, 'DefaultFigureVisible', 'on'); 

See here for more information on setting default values ​​for properties.

+2
source

You need to save the handle of each shape to an array, for example. you can use the command set(h(index),'visible','on')

0
source

Source: https://habr.com/ru/post/973664/


All Articles