Close a Simulink mask using M-Code - matlab

I have been looking for a solution on the mathworks but found nothing. I need to control opening and closing of a simulink mask using code.
I can open the mask with:
open_system(gcb, 'mask')
But I cannot close it with:
close_system(gcb, 'mask')
Solution must work on matlab 2011b & 2014b
Any clue ? I need to support a block on both matlab 2011b and 2014b and the work flow and behavior are different, forcing me to control a mask close/open under certain circumstances.

Found it,
close_system(gcb)
Is enough. Don't know why it didn't work the first time however.

Related

X11 MATLAB Display Figure

I know it's possible to forward any output from a remote machine to a local one by using the X11 forwarding remote tunnelling, so that when you run a MATLAB command it will display all the graphical outputs back to the machine you've connected from.
My question is:
Is there any MATLAB command to just output the figures (e.g., plot,surf,etc.) without displaying any other graphical object (i.e., the main interface)?
In practice, I would like to interact with MATLAB by using the command line (as shown below) and forward back only the figures.
MATLAB cannot display figures without its own figure-GUI, so the answer to your question would be no.
However: there is a workaround: create an invisible figure using f=figure('visible', 'off'), then plot your data, and finally use saveas(f,filename,fileextention). Don't forget to close(f) your figure after saving, to free the RAM. You'll now have a figure in your file directory, which you can display using your favourite visualising tool, which might even be possible through a call to system, although I have never tested that.

How to prevent Matlab from hanging entire system? Disable swapping

It is very easy to hang entire system with Matlab. It is sufficient to run any operations on very large matrices to do this.
In hang situation Matlab is apparently neither give the system to work and nor works itself. I.e. this "operation mode" is completely useless and harmful.
Is it possible to disable Matlab from jumping over it's head? Is it possible to disable/minimize swapping or something?
It would be much better if Matlab just fail to complete an operation than if it is simulating some work which is not true.
This guide outlines a few strategies that you can put to use
http://in.mathworks.com/help/matlab/matlab_prog/resolving-out-of-memory-errors.html

MATLAB gui freeze after running my program

I create a GUI that use Parallel computing for accelerating Neural network and SVM models. When I enable Parallel computing in my GUI all thing (MATLAB,My GUI and my code's window) will freeze and I can't maximize these windows either, but my program is working,using workers and sometimes I can see updates in graphs and values of GUI. When I disable Parallel computing in my program everything is normal. In first situation sometimes my GUI turns to black color (Background of GUI,buttons,text-boxes and edit-boxes are good) but values are updating in iterations of created GUI.
What is this problem?
Thanks.
Sorry for the late answer. It is hard to give a definite answer to a solution here. The problem is quite advanced and most of the code we cannot do anthing about. What happens in parfor is probably that matlab puts some kind of lock (mutex or something else) on the elements it accesses at the moment. Also, since parfor works in parallel it is unlikely that any of the data in the loop is ever untouched. The only solution I can see is that you run shorter processes. That will allow your gui to update between the prcesses.
It would probably work to put a drawnow where you want the gui to update.
Other options could also be to place the gui in a location where you does not need to move it or dock it to the main window in matlab. But these are shortcuts which will only hide the problem.

How can I check how does a MatLab function work? I want to check the algorithm for dspdata.psd

I am trying to make Power Spectral Density function in Mathematica and seems like MatLab dpsdata.psd works quite well. Now, I want to implement this to Mathematica but I need how it works and its algorithm. How can I check this?
Type edit dspdata.psd in the Matlab shell. You'll see the code, mostly comments, and then a call to initialize. Click on that word and hit F4. You'll then see the code you are looking for.
You can use open dspdata.psd or edit dspdata.psd in the MATLAB Command Window to view the source code. You can also call open initialize, which will bring up the key function in dspdata.psd.
It may help to review MathWorks's reference pages for this function, available here http://www.mathworks.com/help/signal/ref/dspdata.html and here http://www.mathworks.com/help/signal/ref/dspdata.psd.html.

Increase matlab figure resolution, when saving in headless mode

I have a plot, which I want to save with a bigger resolution. But the documentation states that Matlab ignores '-r' option to print command, when running in a headless mode. Is there some other way to increase printed figure resolution?
You could use the function export_fig written by Oliver Woodford. Its -r option (resolution) also works in headless mode. The function is available here.
As suggested above, export_fig provides a solution, but in later versions of Matlab, it may take a fair amount of tinkering to get it working.
export_fig(gcf, 'figure.png', '-png','-painters','-m2');
Should do the trick. The critical parameters here are:
'-painters' which forces matlab to use the correct rendering engine. The default (OpenGL) does not work in -nodisplay mode and "zbuffer" is no longer supported in recent version of matlab.
'-m2' which indicates output at x2 resolution. You can obviously specify '-m3' for x3 resolution and so on.