Creating a list to select graphs on figure
2 次查看(过去 30 天)
显示 更早的评论
I want to create a list using uicontrol('Style','listbox') where a figure will pop up and the user can choose which data appears on the graph by control clicking different functions in the list and then them all appearing on the graph unless the user deselects it. Note: I will use 'Callback' and then previous functions that were already made (e.g. sin, cos).
4 个评论
回答(1 个)
Gaurav Ahuja
2017-6-6
From what I could understand about the situation after reading the conversation in the comments is that you are unable to access the value selected in the listbox.
it is because ListBoxCheck is a cell array. Also, it is the same array that is entered by you in 'uicontrol' when you typed ` 'String', {'sin(x)','cos(x)'},... `. so the execution of the following command results in a '2×1 cell array'
if true
ListBoxCheck = get(lst,'String')
% command window output is as following
ListBoxCheck =
2×1 cell array
'sin(x)'
'cos(x)'
end
The Value property stores the row indexes of currently selected list box items.
if true
ListBoxCheck = get(lst,'Value')
% command window output is as following
ListBoxCheck =
1
end
To enable multiple select, you can go through the following documentation link and search for 'listbox' under section 'Specifying the Uicontrol Style'. This should be of good help to you for solving you querry.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!