Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Capacity of a listbox

1 view
Skip to first unread message

Kyung Ho Park

unread,
Sep 2, 2010, 5:03:19 PM9/2/10
to
Hi,
Does anyone now if there is a limitation in the number of strings a listbox can hold?
I tried putting in 28 strings, but noticed that only 27 were displayed.
My strings are about 20 characters or so each.

Is this (small) capacity correct? If it is, too bad...

Jan Simon

unread,
Sep 2, 2010, 5:21:06 PM9/2/10
to
Dear Kyung Ho Park,

No, a listbox can carry more than 27 strings. Just try it:
C = cell(1, 32);
for iC = 1:32
C{iC} = sprintf('line %d', iC);
end
uicontrol('style', 'listbox', 'string', C);

Therefore I conclude, that another mistake causes, that you see too few strings.

Jan

Walter Roberson

unread,
Sep 2, 2010, 6:47:57 PM9/2/10
to
On 10-09-02 04:03 PM, Kyung Ho Park wrote:

> Does anyone now if there is a limitation in the number of strings a
> listbox can hold?

Not off-hand, but somewhere over 1500, as I have used that much before.

Jan Simon

unread,
Sep 3, 2010, 12:46:19 PM9/3/10
to
Dear Kyung Ho Park,

> > Does anyone now if there is a limitation in the number of strings a
> > listbox can hold?
>
> Not off-hand, but somewhere over 1500, as I have used that much before.

It works well with 40.000 strings also. A problem is just the speed:
In Matlab 6.5 using a single string with | as separator is remarkably faster:
| method: 3.9 sec, cell string: 23.4 sec
In Matlab 2009a the | method is nearly unusable for large strings, while a cell string is obviously implemented with care:
| method: 63.3 sec, cell string 0.4 sec

BTW: Creating a |-separated string was very slow with SPRINTF. CStr2String (published in the FEX) is 40 times faster for 40.000 strings.

So, Kyung, where ist the problem?

Kind regards, Jan

0 new messages