fig2cmd

fig-file to command-strings converter
2K Downloads
Updated 17 Jul 2006

No License

command_strings = fig2cmd(figfile,varargin)

This routine is meant for users (like myself) who wish to enjoy the graphical design capabilities of GUIDE, but avoid the large amount of code it generates. The routine takes the figfile and extracts the gui objects (figure, axes, uicontrol etc.) and their properties (position, string, tag, etc.) to a cell arr of valid command strings. These strings can then be pasted in code or even sent to eval.

The routine wasn't tested on all possible gui-objects and configurations, but the basic apparatus should apply to all objects, with little or no adaptation. Please let me know if any gui-objects or props causes problems : ofek@REMOVETHISsimbionix.com

Several modes of operation are available:
cs = fig2cmd(figfile, proplist) ,
generages the commands reproducing the GUI, with specified props stated explicitly.

cs = fig2cmd(figfile, 'nondefault', ... )
generates commands specifying only nondefault properties among the given ones.

cs = fig2cmd((figfile, 'exclude',...)
generates commands specifying all properties (optionaly 'nondefault') excluding those given as arguments.

There is a hard-coded default property list and basic exclude properties.
You can modify them manually at the beginning of the m-file.

Example :

cs = fig2cmd('myfig.fig', 'units','position')

may produce output similar to -

cs =
'figure('units','characters','position',[112 31.38462 49 25.15385])'
'uicontrol('units','characters','position',[6.2 7.23077 33.8 1.30769])'
'axes('units','characters','position',[5.6 3 36.4 3.84615])'


cs = fig2cmd('myfig','nondefault','exclude', 'CData')

would generate GUI commands with comprehensive nondefault property list as arguments, excluding the color data of the gui objects.

Cite As

Ofek Shilon (2024). fig2cmd (https://www.mathworks.com/matlabcentral/fileexchange/11159-fig2cmd), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Interactive Control and Callbacks in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0

description typos fixed