简体   繁体   中英

Inputdlg in MATLAB

I have a figure window on MATLAB. I want the user to type in his answer on that figure window. The code I am using is :

> prompt = {'Your Age: '}
> dlg_title = 'Bio data'
> answer = inputdlg(prompt,dlg_title)'

This is the figure which I am getting.

在此输入图像描述

My Questions :

1) How to make the age, which I type in this dialogue box, appear up at a specific position ON my figure window once I click on "ok" button of this dialogue box.

2) How to put up a customized background on this dialogue box.

3) How to get the user input ON the figure window without the dialogue box. like shown in the picture given bellow : (so that answer is typed on the horizontal line and vertical line is the cursor)

在此输入图像描述

This might be close to what you want,

function age = AgeDB()
f = figure;
set(f,'Position',[200 350 350 150],'Color',[.4 .6 .4],'MenuBar','none',...
    'Name','Bio data','Visible','off');
bc = [.4 .6 .4];
ht = uicontrol('Style','text','Position',[30 80 160 40],...
    'String','Your Age:','FontSize',20,'FontWeight','bold',...
    'BackgroundColor',bc,'ForegroundColor','w');
he = uicontrol('style','edit','Position', [200 80 120 40],...
    'BackgroundColor',bc,'FontSize',20,'FontWeight','bold',...
    'ForegroundColor','w','Callback',{@Age_Callback});
hp = uicontrol('Style', 'pushbutton', 'String', 'Ok',...
    'Position', [150 10 50 20],...
    'Callback', 'close'); 
movegui(f,'center')
set(f,'Visible','on')
waitfor(he)

    function Age_Callback(hObject,eventdata)
         age = str2double(get(hObject,'string'));
    end
end

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM