Can you make it impossible to close this window in Matlab?

I run a duration simulation and align the results in a given chart window to compare them. If I accidentally close the graph window, these graphs will be lost, and I must repeat the simulations. Is there a way to make it impossible to close this chart window (for example, by disabling the "X" icon)?

A direct alternative, of course, would be to save the results in variables and run a small script graph to build them, but I find this less convenient in this case.

+4
source share
1 answer

You need to replace the actual request to close the window with something β€œinert”. The following code should do what you want:

figure('CloseRequestFcn', @(h,e) fprintf(1, 'Not allowed, use "close %d force"\n.', h));

Please note that this will not make it impossible: this will prevent accidental closing of the window, but if your colleagues make practical jokes about how to mess with your work, then this must be decided at the person level, and not at the programming level.

+9
source

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


All Articles