Add Available serial port into pop up menu

1 次查看(过去 30 天)
Hi,
I wish to get a list of available serial port in my computer and display them in the pop up menu. code:
a=instrfind('Type','Serial');
for i=1:length(a)
text{i}=a(i);
end
set(handles.popup1,'String',text);
guidata(hObject,handles);
but, there's nothing shown in the pop up menu. May i know which part i did wrongly? Thanks
  1 个评论
Walter Roberson
Walter Roberson 2012-6-17
Please do not name a variable "text" as that conflicts with the important graphic function "text".

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2012-6-17
a = instrfind('Type','Serial');
for i = 1:length(a)
portnames{i} = get(a(i), 'Port')
end
set(handles.popup1, 'String', portnames);
  3 个评论
Shawn Chang
Shawn Chang 2012-6-21
size(a)
ans =
0 0
>> get(a(1))
??? Index exceeds matrix dimensions.

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by