开发者

In Matlab, how do I create a GUI to interface with 3 existing m files?

Hi I am trying to create a GUI to link to my 3 m files.

1) findcontrolpoints.m 2) morph.m 3) morphvideo.m

In 1), I need to get user input of the number of points. The input will be entered in the GUI, the开发者_StackOverflow中文版n I wish to pass the variable on to the findcontrolpoints.m file for processing. This is will done by pressing pushbutton1. Is there any way to do that?

function inputpoints_Callback(hObject, eventdata, handles)
% hObject    handle to inputpoints (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of inputpoints as text
%        str2double(get(hObject,'String')) returns contents of inputpoints as a double
input = str2num(get(hObject, 'String'));

if (isempty(input))
    set(hObject, 'String', '50')
end
guidata(hObject, handles);


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% hMainGui = getappdata(0, 'hMainGui');

% fileName = uigetfile('*.jpg');
points = get(handles.inputpoints,'String');

findfeaturepoint(points);


Would something like this work for you ? I just re-used an old piece of GUI from another project, so you can pretty much get rid of all the options and it will still work.

function interface
% Main figure
figure('units','normalized',...
    'position',[0.25 0.25 0.5 0.5],...
    'color',[1 1 1]*0.5,...
    'numbertitle','off',...
    'name','Interface',...
    'menubar','none',...
    'toolbar','none',...
    'tag','main');
% Data structure
data=guihandles(gcf);
% Input field
uicontrol('parent',data.main,...
    'style','text',...
    'string','Number of points',...
    'horizontalalignment','center',...
    'backgroundcolor',[1 1 1]*0.5,...
    'units','normalized',...
    'position',[0.4 0.7 0.2 0.1]);
uicontrol('parent',data.main,...
    'style','edit',...
    'horizontalalignment','center',...
    'string','0',...
    'backgroundcolor',[1 1 1],...
    'units','normalized',...
    'enable','on',...
    'position',[0.4 0.6 0.2 0.1],...
    'tag','input');
% Submit
uicontrol('parent',data.main,...
    'style','pushbutton',...
    'string','Submit',...
    'units','normalized',...
    'enable','on',...
    'position',[0.4 0.45 0.2 0.1],...
    'tag','submit',...
    'callback',@submit);
% Data structure
data=guihandles(gcf);
% Program parameters
data.default=50;
% ... %
guidata(gcf,data);
end
% Callbacks
function submit(obj,event) %#ok
% Data structure
data=guidata(gcbf);
input=get(data.input,'string');
% Input validation
% ... %
% Functions call
% ... %
guidata(gcbf,data);
end

You just have to call your three functions from the callback after valdating the input.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜