GUI I want to take datas from a struct into my listbox

조회 수: 1 (최근 30일)
Mahbube
Mahbube 2014년 12월 25일
댓글: Shoaibur Rahman 2014년 12월 26일
Hello;
First of all I'm new at MATLAB, have some problems and couldn't find anything on the net.
I have a struct array 'patient', and this array has the fields 'name', 'surname', 'age', 'ID', 'phoneNum' etc.. I want to display the fields surname and name side by side but separated with a comma on a listbox.
For example;
patient(1).name = NAME1;
patient(1).surname = SURNAME1;
patient(2).name = NAME2;
patient(2).surname = SURNAME2; ...
I wanna display
SURNAME1, NAME1;
SURNAME2, NAME2; ...
on listbox.
Thanks in advance.

채택된 답변

Shoaibur Rahman
Shoaibur Rahman 2014년 12월 26일
There are multiple ways to do so. One of them: I assume you have a pushbutton to display in the names in the listbox. And if so, load your patient data and add the following lines of code under the pushbutton callback function.
for k = 1:number of patients
c{k} = [patient(k).surname,', ', patient(k).name];
end
set(handles.YourListBoxTag,'String',c')
  댓글 수: 2
Mahbube
Mahbube 2014년 12월 26일
That's exactly what i was looking for. I understood my mistake.
Thank you so much.
Shoaibur Rahman
Shoaibur Rahman 2014년 12월 26일
No problem. Thank you very much for accepting my answer.

댓글을 달려면 로그인하십시오.

추가 답변 (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