GUI Examples #21:Explore multiple-figure data-passing 2
function [] = GUI_21() % Demonstrate how to get data from one GUI to another (data passing). % Creates a GUI with an editbox and a pushbutton. When the user presses % the pushbutton, another GUI pops up with an editbox. Whatever is in the % editbox of the second GUI when the user hits return will be put into the % edit box of the first GUI. % % Suggested exercise: Alter the code to have the new GUI display whatever % text is in the editbox from the first GUI when the new GUI is created. % Even more advanced: Alter the code so that two new GUIs cannot be % launched simultaneously by pressing the pushbutton repeatedly. % % % Author: Matt Fig % Date: 7/15/2009 S.fh = figure('units','pixels',... 'position',[500 500 200 130],... 'menubar','none',... 'numbertitle','off',... 'name','GUI_21',... 'resize','off'); S.ed = uicontrol('style','edit',... 'units','pix',... 'position',[10 60 180 60],... 'string','Data'); S.pb = uicontrol('style','pushbutton',... 'units','pix',... 'position',[10 20 180 30],... 'string','Push to Get Data',... 'callback',{@pb_call,S}); function [] = pb_call(varargin) % Callback for GUI_21 pushbutton. S = varargin{3}; % Get the structure. f = figure('units','pixels',... 'menubar','none',... 'position',[750 510 200 100]); % Create a new GUI. E = uicontrol('style','edit',... 'units','pixels',... 'position',[10 20 180 60],... 'string','Type something, press return.',... 'callback',{@E_call,varargin{3}}); uicontrol(E); % Allow user to simply hit return without typing anything. % If user closes GUI_21, close new one as well because it will error when % it tries to execute the callback otherwise. set(S.fh,'deletefcn',{@fig_delet,f}) function [] = E_call(varargin) % Callback for secondary GUI editbox. S = varargin{3}; % Get the structure. set(S.ed,'string',get(gcbo,'string')) % Set GUI_21 editbox string. close(gcbf) % Close secondary GUI. function [] = fig_delet(varargin) % Executes when user closes GUI_21. try delete(varargin{3}) catch % Do nothing. end
Popularity: 1% [?]
Geometric Primitives and Geomtric Operations with Matlab
Matlab does not come by default with a geometric primitives library. About for some simple function like the “sphere” command, using some geometric entities may be an issue. Fortunately on Matlab file exchange are available these two packages, from David Legland ,that help us to develop geometric projects.
- Geom2D Download Now
- Geom3D Download Now
The packages include functions for computations on planar and spatial geometrical shapes (points, lines, circles, polygons…)
The goal is to provide a low-level library for manipulating geometrical primitives, making easier the development of more complex geometric algorithms.
The library proposes functions to:
- create various shapes (points, circles, lines, ellipses, polylines, polygons) using an intuitive syntax. Ex: createCircle(p1, p2, p3) to create a circle through 3 points.
- derive new shapes: intersection between 2 lines, between a line and a circle, parallel and perpendicular lines
Functions to compute intersections - work on polylines and polygons: compute centroid and area, expand, clip with half-plane…
- measure distances (between points, a point and a line, a point and a group of points), angle (of a line, between 3 points), or test geometry (point on a line, on a circle).
- manipulate planar transformation. Ex: P2 = transformPoint(P1, createRotation(CENTER, THETA));
- draw shapes easily. Ex: drawCircle([50 50], 25), drawLine([X0 Y0 DX DY]). Some clipping is performed for infinite shapes such as lines or rays.
- functions for 3D polygons and polyhedra. Polyhedra use classical vertex-faces arrays (face array contain indices of vertices), and support faces with any number of vertices. Some basic models are provided (createOctaedron, createCubeoctaedron…), as well as some computation (like faceNormal or centroid)
- direct drawing of shapes with specialized functions. Clipping is performed automatically for unbounded shapes such as lines or rays. Ex:
drawPoint3d([50 50 25; 20 70 10], ‘ro’); % draw some points
drawLine3d([X0 Y0 Z0 DX DY DZ]); % clip and draw straight line
Popularity: 1% [?]
The Advanced Matlab Code Page got 500 members!
A good news, the Advanced Matlab code facebook page reached 500 members, and it is not over yet!
Keep subscribing:
Follow Us On:
Facebook
Popularity: 1% [?]




















































