简体   繁体   English

在Matlab中编辑字段

[英]Editing fields in matlab

I am creating message box in MATLAB with the following code 我正在使用以下代码在MATLAB中创建消息框

prompt={'Length'}
name = 'Input';
answer = inputdlg(prompt,name,[1 40],defaultans);
Length = str2double(answer{1});
choice = questdlg('Would you like to confirm?', ...
    'Message Box', ...
    'Yes','No','No');
    switch choice
    case 'Yes'
    h = msgbox({'Operation' 'Completed'});
    case 'No'
    h = msgbox({'Operation' 'Failed'});
    end  

I am entering the value as shown in below image 我输入的值如下图所示

在此处输入图片说明

After moving to next window, when i press 'No' , I want the same earlier Input window as shown above to be displayed with 120 written inside the input box so that i can change the value. 移至下一个窗口后,当我按'No'时,我希望显示与上述相同的先前Input窗口,并在输入框中写入120,以便我可以更改该值。

Can anyone please let me know how to switch to previous window wherein i can edit my values which have been earlier written. 任何人都可以让我知道如何切换到上一个窗口,在该窗口中我可以编辑先前编写的值。

Use an infinite while loop and put the inputdlg statement inside it. 使用无限的while循环,然后将inputdlg语句放入其中。 When the user confirms, break it. 用户确认后, breakbreak

Modified Code: 修改后的代码:

prompt={'Length'};
name = 'Input';
defaultans={'120'};
while 1
    answer = inputdlg(prompt,name,[1 40],defaultans);
    choice = questdlg('Would you like to confirm?', ...
        'Message Box', ...
        'Yes','No','No');
    switch choice
        case 'Yes'
            h = msgbox({'Operation' 'Completed'});
            Length = str2double(answer{1});
            break;
    end
end

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

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