Undefined function error when passing data in multiwindow apps
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Patrick Mirek
il 22 Mar 2022
Commentato: Patrick Mirek
il 13 Apr 2022
Hello,
I'm trying to create a multiwindow app. The way I've got it setup, is the user will make some selections on the main app, click a button, and if a certain condition is met based on their selections, a second app window will open where they will make some additional inputs. Once complete, they will click a button which will send their inputs back to the main app and resume its execution (in order to create a graph in Excel, in my case). I've followed the instructions in the MathWorks documentation for this (Create Multiwindow Apps in App Designer - MATLAB & Simulink (mathworks.com)), but I am getting an error which says "Undefined function 'addVariableUnit' for input arguments of type 'double'.", where 'addVariableUnit' is the public function in my main app, which I am calling from the second app, in order to pass over the users inputs. It seems that the second app does not recognize this function, even though I've made it public in the main app. Below is my code. I've attached the mlapp files as well, where the lines of interest in the main app are 100-106 (calling the second app), 162-174 (public function in the main app to retrieve second apps data). The second app is quite short.
Main app (createChart_App.mlapp):
methods (Access = private)
function [yTitle1] = createChartErrorChecks (app, wb_proc, A, axis)
...
%checking condition based on users selections
if yUnit == "none"
%Open second app window
app1 = enterVariableUnit;
%pause execution until window is closed
while isvalid(app1); pause(1); end
end
end
end
methods (Access = public)
%public function to pass data from second app to main app
function addVariableUnit(app, variable, unit)
%do stuff with variable and unit
...
end
end
Second app (enterVariableUnit.mlapp):
properties (Access = private)
CallingApp % Main app object
end
methods (Access = private)
% Button pushed function: EnterButton
function EnterButtonPushed(app, event)
%call main apps public function, provide it with the users inputs
addVariableUnit(app.CallingApp, app.variableUnit.Value, app.variableName.Value);
delete(app)
end
end
0 Commenti
Risposta accettata
Reshma Nerella
il 12 Apr 2022
Hi,
In the function "createChartErrorChecks" in the main app, you need to open the dialog app by passing the main app as the argument.
Instead of
app1 = enterVariableUnit;
Use the following line of code: Create a private property "DialogApp" and pass the main app as argument.
app.DialogApp = enterVariableUnit(app);
For more information, refer to the following documentation page: Create Multiwindow Apps in App Designer
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!