Listbox problem in GUI

2 次查看(过去 30 天)
I have a GUI which has listbox in which I want to display numbers in first followed by strings or names The excel file has numbers and texts/names. How can I display both numbers and text in listbox using pushbutton callback Matlab is treating text as 'NaN' and I want to convert them to strings and display as text in listbox ...

采纳的回答

Walter Roberson
Walter Roberson 2018-6-24
You need to initialize the listbox as a cell array and use {} indexing with it. For example,
s = {3; 'hello'};
h = uicontrol('style','list','string', s);
...
hv = get(h,'Value');
hall = get(h,'String');
hcurrent = hall{hv}
  6 个评论
VBBV
VBBV 2018-6-24
it show 59 x 3 char array
Walter Roberson
Walter Roberson 2018-6-24
It is not possible for a numeric array to contain both text and numbers.
If you are using xlsread() then the first output would be pure numeric with no text, and the second output would be pure text with no numeric, and the third output ("raw") would be a cell array in which individual entry could be either numeric or character vector. As that is the only way to get a mix of numeric and text with xlsread(), I assumed that you were working with that third output of xlsread()
I just corrected a typing mistake in the code I posted.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by