Plotting Selected Items from a List

조회 수: 25 (최근 30일)
autumn
autumn 2019년 6월 5일
댓글: Geoff Hayes 2019년 6월 6일
I have been trying to figure out how I can plot one or more items that the user chooses from a list. I have 22 items in total that each have their own specific plots. Is there any way I can do this? So far, I have used listdlg() and if-else statements, but that only works if I only want to plot one item.
  댓글 수: 6
Star Strider
Star Strider 2019년 6월 5일
Consider using the any function:
any(objects == 1)
Geoff Hayes
Geoff Hayes 2019년 6월 5일
Since objects is a 1x2, does that mean you have selected the first and eigth item in the list box? How are you then extracting the coordinates from the structure? Please show the code to do this.

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

채택된 답변

Geoff Hayes
Geoff Hayes 2019년 6월 5일
편집: Geoff Hayes 2019년 6월 5일
autumn - try the following
[objects] = listdlg('ListString',... % my 22 objects are inserted here
'PromptString','Select an item:',...
'SelectionMode','multiple',...
'OKString','Plot',...
'CancelString','Exit');
for k = 1:length(objects)
index = objects(k);
% get the coordinates for this object
plot3(coordinates);
hold on;
end
The above code will iterate over each selection (index) that you have selected in the list. The coordinates for that selection will be drawn and then, using hold on be retained when you try to draw the next selection.
Or you could combine your coordinates (from each selected object) in such a way that you just call plot3 once with the combined coordinates for the X, Y, and Z. See plot3 for details.
  댓글 수: 6
autumn
autumn 2019년 6월 5일
편집: autumn 2019년 6월 5일
I got everything to work! Thank you so much for all of your help!
Geoff Hayes
Geoff Hayes 2019년 6월 6일
You're welcome! :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by