As when you use subplot to display plots side by side in the same window, I would like a similar function that can do the same for multiple figures. This works:
subplot(2,2,1)
and I am looking for something like this:
subfigure(2,2,1)
Does a build-in function with this advantage exist?
You could write one such function yourself. The idea is to get the screen size:
get(0,'ScreenSize')
then divide it up into sub-regions according to the input parameters. You would also need to account for margins in-between.
Another idea:
create an invisible figure (preferably same aspect ratio as the screen)
call subplot inside it
capture the position of the created axis
delete figure
scale the position captured to fit the screen size, and use it to create the actual figures.
Related
I used Matlab GUIDE to create a GUI.
It is displayed mid-screen.
How can I position it at the top of the screen; so that the top edge of the GUI window is at top of screen.
It will be used on different Windows 7 computers with different screen resolutions.
I tried to set hObject.Position(2) but it doesn't do what I want.
I think the simplest way would be to use movegui in the OpeningFcn of your GUI with the appropriate argument, i.e. using either 'north', 'northeast' or 'northwest'.
The calling syntax is quite simple, using the handles to the figure created. In GUIDE, the default name for figures is "figure1", so in your case the code would look like this (unless you changed the figure's name):
movegui(handles.figure1,'northwest') %// or whatever
Note that movegui calls the following 3 functions to get the screen size and monitor positions/units:
screensize = get(0, 'ScreenSize');
monitors = get(0,'MonitorPositions');
old0units = get(0, 'Units');
So you could do the same to make the calculations yourself in order to place the figure precisely where you want if the above solution is not sufficient for you.
I have used matlab's preview window in the following syntax:
figure('Name', 'My Custom Preview Window');uicontrol('String', 'Close', 'Callback', 'close(gcf)');
I am able to successfully get the video stream. Now I want to have a small circle as a region of interest to return the average pixel value within this circle. I want this to be stored and named after a click of a button and recalled later for the further processing.
Could anyone guide me where I can start with?
Please note I dont want user to define ROI instead its always fixed as a small circle at the centre of field view. Whatever the colours comes within the circle I want mean values to be calculated and stored as a reference.
Ps: I am not sure I am correct in calling ROI its simple circle in the field view
You might want to try using a Matlab gui instead of a simple figure. Then you could try something like this.
I have two CT image . How can I draw multiple ROIs on both image and calculate mean difference between each the corresponding ROIs with matlab ? I've used the 'imrect' or 'imellipse' but this commands creates the Mask which makes the image as binary image then I would have problem with to calculate mean difference .
How to show the images with the ROIs draw on them?
Not very sure about what you want to do with imrect. This is an idea; the way I would do it. You have to get your hands dirty with actual programming instead of GUI, but it's VERY basic stuff, and easy as soon as you understand indexing, which is very nice in MatLab and the thing you should take with you from this answer:
First of you define the size of your ROIs, which can be easily made with a variable
width=20; %or whatever you wish
height=10;
then define the multiple ROIs using their upper left corner for the position
ROI11=Image1(corner1:corner1+width,corner1:corner1+height); %(width and height eventually the other way around, whatever)
ROI12=Image1(corner2:corner2+width,corner2:corner2+height);
%...
ROI21=Image2(corner1:corner1+width,corner1:corner1+height);
ROI22=Image2(corner2:corner2+width,corner2:corner2+height);
%...
and then calculate the mean however you please, like for example:
Mean1=sum(ROI11-ROI21)/length(ROI11(:));
Mean2=sum(ROI11-ROI21)/length(ROI11(:));
%...
or something along those lines.
Give it a try and play a bit with it.
Does any one here have an idea about how to change the position of output in the GUI matlab to be to the right side of the box and not in the center ?
i think I have to change some properties of the result text box
Check this post out: Positioning of figures
The figure Position property controls the size and location of the figure window on the screen. Monitor screen size is a property of the root Handle Graphics object. At startup, the MATLAB software determines the size of your computer screen and defines a default value for Position. This default creates figures about one-quarter of the screen's minimum extent and places them centered left to right, in the top half of the screen.
The Position Vector
MATLAB defines the figure Position property as a vector. So you may use a figure and text into it, e.g.
figure(gcf)
text(offsetX1, offsetX1, ['result 1: ' num2str(result1)])
text(offsetX2, offsetX2, ['result 2: ' num2str(result2)])
Displaying analytical results in a MATLAB GUI
This post talks about adding a static textbox with your results and positioning it.
Move GUI figure to specified location on screen:
Syntax:
movegui(h,'position')
movegui(position)
movegui(h)
movegui
The answer is pretty much trying to cover up the vauge nature of the question
I have 8 figures and one textbox (a legend listing the values of simulation parameters). They're all plotted in one window using subplot(). It looks nice, but the window pops up too often and distracts me from my other work. I'd like to automatically save these figures as PNG images rather than having the window keep popping up so I can review the plots and figures later.
What I do know:
How to save a single figure as a PNG
How to use subplot to make multiple figures in a single window
How to not display a window with a single figure (one sets the figure's visibility to 'off')
What I don't know:
How to make a multi-figure window not pop up
How to set the size of a multi-figure window (say, 400 px by 600 px)
How to export the entire window to PNG
Any thoughts would be much appreciated. Thanks in advance!
use
set('gcf','visible','off')
to off showing all figures, and
set('gcf','visible,'on')
to turn showing figures on.
to save a figure first assign a name to it:
fig1 = figure(1);
then use saveas:
saveas(fig1,'filename.png','png')
to set figure size, see: Setting graph figure size