How can I make an input dialog box created by INPUTDLG wide enough to show the entire title?

160 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 6 Mar 2013
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.
Soroush Asarzadeh
Soroush Asarzadeh on 15 Mar 2016
Hello, Can I also apply it to a warning dialog box. I want to make it wider, because my title exceeds the box! Thanks in advance. here is my code:
warndlg('Die Ergebnisse können ungenau sein!','Singularitätswarnung')
here is the result:

Sign in to comment.

More Answers (3)

Ints on 28 Oct 2016
One can use a simple trick:
  • set Interpreter to 'tex'
  • use a long enough prompt string with hidden symbol (color=the same as bg) at the end, like that:
options.Interpreter = 'tex';
answer = inputdlg('Prompt: \color{white} .','Title',1, {'Default'}, options);
  1 Comment
Massimo Ciacci
Massimo Ciacci on 7 Aug 2017
This is in fact the most practical solution which works also with different argument list. I took this one in the end.

Sign in to comment.

Phoenix on 17 Jun 2016
I tried the programming approach, it doesn't work.
Gives the following error: Error using figure While setting the 'Resize' property of 'Figure': Value must be specified as the string 'on' or 'off'
Manual approach works, but I want to use the programming approach.

Helton Pierre
Helton Pierre on 4 Sep 2016
Example Solution:
prompt = {'Name = ','ID = ','FONE = '...
'Address = '};
nometitle = (['EXEMPLE']);
dlg_title = nometitle;
size_wind = [1 50; 1 50; 1 50; 1 50]; % Windows size
defaultans = {'Brazil','+55',' 9999-9999','Natal - RN'}; %default
options.Resize = 'on';
%options.WindowStyle = 'normal';
Janel = inputdlg(prompt,dlg_title,size_wind, defaultans,options);
name = char(Janel(1));
id = str2num(char(Janel(2)));
fone = str2num(char(Janel(3)));
address = char(Janel(4));
See the tutorial 3:
Pierre, Natal-RN 04/09/2016


Find more on Migrate GUIDE Apps in Help Center and File Exchange





Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!