The ability to use the "\t" format in a listbox in MATLAB to place a tab in a string expression is not available.
As a workaround, you can use spaces along with a fixed-width font to align the columns.
figure
h1 = uicontrol(gcf, 'style', 'listbox', ...
'position', [100 100,300,100], ...
'background', [1 1 1] );
data1 = 1:0.1:3;
data2 = 10:1:30;
for k = 1:21
str(k) = {sprintf('%2i %5.2f %3i', k, ...
data1(k), data2(k))};
end
set(h1, 'string', str )
set(h1,'FontName','FixedWidth')
If you want text to use a fixed-width font that looks good in any locale, you should set FontName to the string FixedWidth
set(text_handle,'FontName','FixedWidth')
This eliminates the need to hardcode the name of a fixed-width font, which may not display text properly on systems that do not use ASCII character encoding (such as in Japan where multibyte character sets are used). A properly written MATLAB application that needs to use a fixed-width font should set the "FontName" property to "FixedWidth" (note that this string is case sensitive) and rely on the "FixedWidthFontName" property to be set correctly in the end-user's environment.
Best Answer