Figure Positioning Tool: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
====Description:====
[[Matlab tools|Back to Matlab Tools]]
A tool to facilitate positioning of figures on a certain location on the screen.


====Usage:====
Position the figure with number ''fignr'' at a desired location and adjust the size if necessary. Run the function pos(''fignr'') in the command prompt of matlab. This will copy a command similar to
''set(1,'position',[1400 530 560 420]);''
to your clipboard. Next, paste this line after the figure(''fignr''); command in your m-file (use CTRL-V). The next time you run the m-file, the figure will be positioned at the desired location.


====File:====
;Files:  
pos.m
Note: Wikipedia automatically changes the first letter of a filename to uppercase. To avoid warnings in Matlab, save the file in lowercase.


====Code:====
;[[File: Pos.m]]


function pos(fig)
 
  posvec=get(fig,'position');
;Description: A tool to facilitate positioning of figures on the screen.
clipboard('copy', ['set(',num2str(fig),',''position'',[',num2str(posvec(1,1)),' ',num2str(posvec(1,2)),' ',num2str(posvec(1,3)),' ',num2str(posvec(1,4)),']);'  ])
 
disp(['Clipboard contains: ' clipboard('paste')]);
    Usage:  pos(figure) or pos figure
disp('Paste this after your figure(fig); command in your m-file.');
   
            example: "pos(3)" or "pos 3" returns the message
            Clipboard contains: set(3,'position',[1717 532 560 420]);  
            Paste this (CTRL-V) after your figure(3); command in your m-file.  
            The next time you run the m-file, the figure will return to this position/size
   
    Inputs:  figure number (takes current figure if called without argument)
   
    Outputs: stores a command on the clipboard
 
 
;Author: Rob Hoogendijk

Latest revision as of 14:34, 15 October 2013

Back to Matlab Tools


Files

Note: Wikipedia automatically changes the first letter of a filename to uppercase. To avoid warnings in Matlab, save the file in lowercase.

File:Pos.m


Description
A tool to facilitate positioning of figures on the screen.
   Usage:   pos(figure) or pos figure

            example: "pos(3)" or "pos 3" returns the message 
            Clipboard contains: set(3,'position',[1717 532 560 420]); 
            Paste this (CTRL-V) after your figure(3); command in your m-file. 
            The next time you run the m-file, the figure will return to this position/size 
   
   Inputs:  figure number (takes current figure if called without argument)
   
   Outputs: stores a command on the clipboard


Author
Rob Hoogendijk