简体   繁体   English

在MATLAB中输入

[英]Inputdlg in MATLAB

I have a figure window on MATLAB. 我在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. 1)当我点击此对话框的“确定”按钮后,如何使我在此对话框中输入的年龄出现在我的图形窗口的特定位置。

2) How to put up a customized background on this dialogue box. 2)如何在此对话框上设置自定义背景。

3) How to get the user input ON the figure window without the dialogue box. 3)如何在没有对话框的情况下在图形窗口上输入用户。 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

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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