Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

getfigure(hObject)
function parent = getfigure(hObject)
% GETFIGURE gets the handle to the parent FIGURE window

% not currently defined for cells
if ~ishandle(hObject)
    % errors
    error('Handle object(s) must be a non-empty array of type ''double''.')
end

% pre-allocates answer
parent = zeros(size(hObject));

% crude array operation is a simple loop
for m = 1:numel(hObject)
    % initialises the loop
    parent(m) = hObject;

    % loops round until it finds a figure or if it was the root
    while ~strcmp(get(parent(m), 'Type'), 'figure') && parent(m)
        % find the parent again
        parent(m) = get(parent(m), 'Parent');
    end

    % checks it
    if ~parent(m)
        % errors
        error('getFigure:parentIsRoot', 'Could not find the parent.')
    end
end

Contact us