我该如何在uitable(GUI)中定义选择列表的每种情况,并为每种选择放置IF函数?

时间:2018-10-09 07:34:43

标签: matlab list uitableview choice

我制作了一个有两个uitable的matlab gui,其中一个在其单元格上具有选择列表格式,但是我不知道如何定义每种选择列表,并为每个列表放置IF函数。换句话说,我要根据另一个ui的选择列表中的情况,将数字从另一个gui应用于第二个uitable。

1 个答案:

答案 0 :(得分:0)

我假设您使用guide来管理GUI,并且您已经创建了一个uitable,其中包含以选择列表格式显示的列,并且您已经设置了{{1 }}属性为true。是这样吗?

然后,在向导窗口的ColumnEditable上单击鼠标右键,创建一个CellEditCallback函数,然后选择“查看回调”->“ CellEditCallback”。如果尚不存在,则会创建回调函数。

自动创建的回调函数可能如下所示:

uitable

在这种情况下,% --- Executes when entered data in editable cell(s) in uitable1. function uitable1_CellEditCallback(hObject, eventdata, handles) % hObject handle to uitable1 (see GCBO) % eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE) % Indices: row and column indices of the cell(s) edited % PreviousData: previous data for the cell(s) edited % EditData: string(s) entered by the user % NewData: EditData or its converted form set on the Data property. Empty if Data was not changed % Error: error string when failed to convert EditData to appropriate value for Data % handles structure with handles and user data (see GUIDATA) 的标签是uitable。如果您的uitable1具有不同的标签,则函数名称将与该标签相同。

现在,将您的uitable块写入此回调函数。例如,如果要查询的选择列表位于if的第一行和第一列中,并且您要检查决策框的选定文本是否为“ blabla”,则您的代码将看起来像这样:

uitable

希望这对您有帮助...