MATLAB: How to make an input dialog box created by INPUTDLG wide enough to show the entire title

MATLABwidewidth

When I execute the following commands:
prompt = {'Rows:', 'Columns:'};
title_text = 'Please enter the desired matrix size';
a = inputdlg(prompt,title_text);
the dialog box is not wide enough to display the entire title.

Best Answer

The ability to automatically set the width of the dialog box created by the INPUTDLG function in MATLAB is not available.
To work around this issue, do one of the following:
1. For the programmatic approach, instead of using the command:
a = inputdlg(prompt,title_text);
use the command:
a = inputdlg(prompt,title_text, [1, length(title_text)+N]);
where "N" is some positive integer. This will set width of input fields of the dialog box to length of the title plus a spacer "N", and increase the width of the dialog box accordingly. "N" should be chosen sufficiently large that the title is shown in its entirety. For example any value above 8 will result in the title being fully displayed.
2. To adjust the width manually, instead of using the command:
a = inputdlg(prompt,title_text);
use the command:
a = inputdlg(prompt,title_text, 1, {'' ''}, 'on');
This will set the "Resize" option of INPUTDLG to 'on', allowing the user to manually resize the dialog box to the appropiate width such that the title is fully displayed.