How to dynamically load struct-data into listbox

1 回表示 (過去 30 日間)
jakkesprinter
jakkesprinter 2016 年 11 月 14 日
コメント済み: Jan 2016 年 11 月 14 日
Hey Guys, i have a struct called DBC. I want to read the following data from this struct into a listbox in a guide GUI. DBC.Message(1).MessageName and DBC.Message(2).MessageName
In my gui, i open a text file and then with a help of another .m-file I read its data into my Struct 'DBC'.
I have problems to visualise data of the struct in a listbox. Here is the code:
if true
function OpenDBC_Button_Callback(hObject, eventdata, handles)
[filename,path,cancel_check] = uigetfile('*.dbc',...
'Choose DBC-File',...
'Multiselect','off');
assignin('base','filename',filename);
assignin('base','path',path);
assignin('base','cancel_check',cancel_check);
DBC_read_test %another m-file, which reads the file and saves its data into a struct 'DBC'
assignin('base','DBC', DBC);
msgs=0;
for msgs = 1:size(DBC.Message) %iterate through the struct
set(handles.MessageList,'Value',msgs);
set(handles.MessageList,'String',DBC.Message(msgs).MessageName);
end
end
My problem is that in the GUI only one entry is displayed, although there are several entries in the struct. Help anyone? THANKS!
  1 件のコメント
Jan
Jan 2016 年 11 月 14 日
The term "path" is an important Matlab command. Shadowing it by a variable is a bad idea.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDialog Boxes についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by