简体   繁体   中英

Editing fields in matlab

I am creating message box in MATLAB with the following code

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.

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. When the user confirms, break it.

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

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