I use cell array of strings to populate popup menu but strings in the popup menu are returned as scientific notation!

2 次查看(过去 30 天)
Dear matlab users
I have 10x1 cell array of strings: 1001001 1001002 1001003 1001004 . . . 1001010
I use this code to set the strings in the popupmenu Matlab GUI:
set(handles.popupmenu14,'String',ListNoSG);
But in the popup menu the strings are shown as scientific notations: 1.001e+06, 1.001e+06, 1.001e+06, 1.001e+06, 1.00101e+06, 1.00101e+06, 1.00101e+06, 1.00101e+06, 1.00101e+06, 1.00101e+06.
Please note that the scientific notation 1.001e+06 is repeated 4 times while 1.00101e+06 is repeated 6 times.
I want in the popupmenu to be shown strings from the cell array: 1001001 1001002 1001003 1001004 . . . 1001010
Please tell me how to do it. I tried several workarounds found on internet but without success.
Thank you in advance.

采纳的回答

Stephen23
Stephen23 2018-7-25
编辑:Stephen23 2018-7-25
It seems that ListNoSG contains numeric scalars. Convert them to character:
tmp = cellfun(@int2str,ListNoSG,'uni',0);
set(handles.popupmenu14,'String',tmp);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Language Fundamentals 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by