how to create a yes or no dialog in matlab

Here is an example code to create a YES / NO dialog box:

main.m
choice = questdlg('Would you like to proceed?', ...
	'Confirmation', ...
	'Yes','No','Yes');
% Handle the response
switch choice
    case 'Yes'
        disp('Ok, proceeding...');
        % Add your code here to proceed with the action related to YES
    case 'No'
        disp('No problem, maybe later...');
        % Add your code here to handle the action related to NO or simply return
end
393 chars
13 lines

In the questdlg function, you specify the question you want to ask the user and the two possible responses: Yes and No.

Once the user selects his answer, the code switches to the corresponding action using a switch statement.

You can replace the disp statements with your own code to perform the desired actions based on the user response.

related categories

gistlibby LogSnag