I'm try to familiar myself with apps designer. How to create a dropdown menu with the list of variables in workspace. so, user only choose their selected variable/dataset.
MATLAB: (App Designer) Dropdown menu detect variables in workspace.
app designer
Related Solutions
I beleive your error is here
% Code that executes after component creation
function startupFcn(app, MainApp, a, b, c) % Store main app in property for CloseRequestFcn to use
app.CallingApp = mainApp; % <----------------------------- HERE
Should be
app.CallingApp = MainApp; % with capital M
Make that change, save the app, close the app, restart it, and test it. If the problem persists, I'd be glad to look further.
Well, yes, for what you want to do to work, you need a way to update your UI_Column dialog whenever your CellSelectionCallback is called. At the moment, there's nothing that tells the dialog that the selection has changed.
One way to do that is to keep around the handle to the edit control in that dialog and update it in the CellSelectionCallback:
classdef app2 < matlab.apps.AppBase % Properties that correspond to app components
properties (Access = public) UIFigure matlab.ui.Figure Panel matlab.ui.container.Panel addrowButton matlab.ui.control.Button UITable matlab.ui.control.Table addcolumnButton matlab.ui.control.Button editnamecolumnButton matlab.ui.control.Button end properties (Access = private) Data_temp=[] % Description
UI_ColumnOldName; % UItextarea for Selecting column name to edit
UI_ColumnNewName; % UItextarea for input of new column name
end methods (Access = private) function name_col(app,new_name) % new name column
app.UITable.ColumnName{(app.Data_temp(2))}=char(new_name.Value); end function SetSelectionName(app) % select old name column
if isgraphics(app.UI_ColumnOldName) %edit dialog is not live is the handle is not valid
app.UI_ColumnOldName.Value = app.UITable.ColumnName{(app.Data_temp(2))}; app.UI_ColumnNewName.Value = app.UI_ColumnOldName.Value; end end end methods (Access = private) % Code that executes after component creation
function startupFcn(app) app.UITable.Data=cell(10,3); % default table
app.UITable.ColumnEditable=true; app.UITable.ColumnName ={'A','B','C'}; % default name
end % Cell selection callback: UITablea
function UITableCellSelection(app, event) app.Data_temp=event.Indices; % salva gli indici nella proprietà Data_temp (creata dall'utente)UITableCellSelection(app);
app.SetSelectionName; end % Button pushed function: addcolumnButton
function addcolumn_ButtonPushed(app, ~) app.UITable.Data(:,end+1)={''}; % add column
column_name=char(inputdlg('column name')); app.UITable.ColumnName{end+1}=column_name; end % Button pushed function: addrowButton
function addrow_ButtonPushed(app, ~) app.UITable.Data(end+1,:)={''}; % add row below
end % Button pushed function: editnamecolumnButton
function editnamecolumn_ButtonPushed(app, ~) if isempty(app.Data_temp) warndlg('select a cell below the desidered column'); % warning: app.Data_temp is empty
else UI_Column=uifigure('Name','Column Name','Position',[100 100 429 276]); app.UI_ColumnOldName=uitextarea(UI_Column,'Position',[100 140 100 22]); app.UI_ColumnNewName=uitextarea(UI_Column,'Position',[220 140 100 22]); % new name column UI_label=uilabel(UI_Column,'Text','new column name','Position',[220 165 100 22]); UI_label_2=uilabel(UI_Column,'Text','old column name','Position',[100 165 100 22]); UI_save=uibutton(UI_Column,'Text','Save','Position',[220 100 100 22],'ButtonPushedFcn',@(UI_save,event) name_col(app,new_name)); % change and save new column name
app.SetSelectionName; %update textarea controls
end end end % App initialization and construction
methods (Access = private) % Create UIFigure and components
function createComponents(app) % Create UIFigure
app.UIFigure = uifigure; app.UIFigure.Position = [100 100 697 560]; app.UIFigure.Name = 'UI Figure'; % Create Panel
app.Panel = uipanel(app.UIFigure); app.Panel.Title = 'Panel'; app.Panel.Position = [114 113 495 382]; % Create addrowButton
app.addrowButton = uibutton(app.Panel, 'push'); app.addrowButton.ButtonPushedFcn = createCallbackFcn(app, @addrow_ButtonPushed, true); app.addrowButton.Position = [23 271 100 22]; app.addrowButton.Text = 'add row'; % Create UITable
app.UITable = uitable(app.Panel); app.UITable.ColumnName = {'Column 1'; 'Column 2'}; app.UITable.RowName = {}; app.UITable.CellSelectionCallback = createCallbackFcn(app, @UITableCellSelection, true); app.UITable.Position = [152 108 302 185]; % Create addcolumnButton
app.addcolumnButton = uibutton(app.Panel, 'push'); app.addcolumnButton.ButtonPushedFcn = createCallbackFcn(app, @addcolumn_ButtonPushed, true); app.addcolumnButton.Position = [24 230 100 22]; app.addcolumnButton.Text = 'add column'; % Create editnamecolumnButton
app.editnamecolumnButton = uibutton(app.Panel, 'push'); app.editnamecolumnButton.ButtonPushedFcn = createCallbackFcn(app, @editnamecolumn_ButtonPushed, true); app.editnamecolumnButton.Position = [19 189 112 22]; app.editnamecolumnButton.Text = 'edit name column'; end end methods (Access = public) % Construct app
function app = app2 % Create and configure components
createComponents(app) % Register the app with App Designer
registerApp(app, app.UIFigure) % Execute the startup function
runStartupFcn(app, @startupFcn) if nargout == 0 clear app end end % Code that executes before app deletion
function delete(app) % Delete UIFigure when app is deleted
delete(app.UIFigure) end endend
Best Answer