run matlab subplot without opening figure [duplicate] - matlab

This question already has answers here:
Render MATLAB figure in memory
(4 answers)
Closed 7 years ago.
I have the following Matlab 2013b code:
subplot(2,2,1);plot(var([c1 c2],0,2)); title('var(c1,c2)');
subplot(2,2,2);plot(var([c3,c4],0,2));title('var(c3,c4)');
saveas(gcf,pth);
I would like to execute this code without opening a figure window in Matlab.
Is this possible? If not, I would like the figure window to be minimized upon plotting.

If you start with a call to figure you can change the visibility:
figure('Visible','Off')
will create an invisible figure window.
The MATLAB documentation on Figure properties also includes this warning:
Changing the Visible property of a figure does not change the Visible property of its child components even though hiding the figure prevents its children from displaying.

Related

MATLAB Image Processing: Show multiple images

Trying to experiment with MATLAB image filtering.
I take the image, use imshow(img), then apply a filter or some other transformation and call imshow(img) again.
For some reason, MATLAB seems to only display the image once, even if I call imshow or imagesc multiple times.
When I did this in Python, when I closed the image window, then the next image would appear. So I thought that until I closed the image window, code execution would halt. But that does not seem to be the case for MATLAB, as closing the image does nothing.
Anyone know why? Thank you.

Matlab: Export a figure made with myaa

I am trying to get better quality phase plots of complex functions made with the Complex Function Explorer of E. Wegert CFE. For this purpose I apply the Matlab anti-aliasing function myaa.m to the phase plots that are made with the CFEGUI.m. For the example screenshot of the result window below I used the setting myaa([8 8]) in the Matlab command window which means that the supersampling enlarge the figure 8x and then downscale it to 1/8 to get the original h x w.
As one can see the window of the figure has no operation icons or menu options for save or print. My question is what to do with such a figure (beside making screenshots)? Can I somehow use export-fig to save such a figure or load it in an image array and if yes, how?
It is also possible to use the setting myaa([8 1]) which results in a very large figure window that is larger than my screen (and has the unpleasant attribute that it can not be moved). It would be even better if such a whole figure could be saved (not only the visible part).
You can use getframe to grab current figure information in pixels.
However, while I do not know how this affects you, notice that MATLAB versions above 2014b (included) have already anti-aliasing. The code you linked seem to be from 2008, I am not 100% sure if it has become obsolete now.

Programatically show data tip on plot [duplicate]

This question already has answers here:
Set data tips programmatically?
(2 answers)
Closed 7 years ago.
How to show data tip message on a matlab plot programmatically with only a mouse click, and without using Data Cursor, to show custom messages in different positions like the following:
"You can't." From the "Tips" section of the help page for the function datacursormode:
You place data tips only by clicking data objects on graphs. You cannot place them programmatically (by executing code to position a data cursor).
But people do achieve this with hacking, like here. The short version of what they are doing is
h = ezplot('sin(x)')
cursorMode = datacursormode(gcf);
hDatatip = cursorMode.createDatatip(h);

How to create axes in matlab GUIDE

I want to implement the following code using matlab GUIDE:
axes(handles.axes1);
imshow(image1);
axes(handles.axes2);
imshow(image2);
As I am very new to GUIDE so I am having no idea how to do this. Any guidance.
Open guide selecting empty gui
Drag and drop two axes objects anywhere in the figure.
Right clicking on any axes object and seeing it properties allows to set size, position, and name of the object.
Guide always generate figure file in parallel with .m file containing all callback functions, among them function to be called on opening the gui (just before it is visible) -you can put you imshow() code there...
The whole thing is very intuitive, and has a great help provided by matlab.

How to save custom-sized figures [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
Printing a MATLAB plot in exact dimensions on paper
How do I save a plotted image and maintain the original image size in MATLAB?
I have recently been trying to create a custom-sized graph in MATLAB and save it automatically using the saveas function. In particular, I am having issues saving the files in the size that I create them. Roughly speaking, my code is as follows:
mygraph = figure('Position',[1,20,1280,1024]);
% creates a figure positioned 1 px from the left of the screen
% 20 px from the bottom of the screen
% that is 1280 px in length and 1024 px in height
% some code to create graph
saveas(mygraph,'mygraphfilename','emf')
% saves figure as mygraphfilename.emf.
So far, my code works fine in that it can create a custom sized graph on my screen, but it seems to save the pictures themselves in a default size. The weird thing is that if I do not use the saveas function and save the figure manually, then the image retains its size.
For clarification purposes, I'm currently saving the graphs as emf, though I'm also open to using jpg/png/bmp if works fine too.
Try setting the following:
set(mygraph, 'PaperPositionMode','auto') %# WYSIWYG
print -dmeta -r0 file.emf