How do I pass data between functions in MATLAB App Designer?
Afficher commentaires plus anciens
I cannot get the syntax correct for passing data between functions using App Designer.
I have tried to follow the instructions in the article "Share Data within App Designer Apps" and can read in and plot data with the LoadHctdataButtonPushed function below.
However, when I invoke the function "BeginoptimizationButtonPushed" below, the value of the data (t, for example) is empty.
I can't see what I am doing differently from the example in the article. Any advice will be greatly appreciated!
Thanks,
Andy
-------------------------------------------------------
properties (Access = public)
t % time vector data
hct % hematocrit data
juf % ultra filtration data
% initial conditions
Vp0
Cp0
Vi0
Ci0
end
% Callbacks that handle component events
methods (Access = private)
% Callback function: LoadHctdataButton, UIAxes
function LoadHctdataButtonPushed(app, event)
filename=uigetfile;%; asks for data file
load(filename);% loads in t, hct(t) and juf(t) and initial SV values
yyaxis(app.UIAxes,'left')
plot(app.UIAxes,t,hct)
yyaxis(app.UIAxes,'right')
plot(app.UIAxes,t,juf,"Color",'r','LineWidth',2);
ylabel(app.UIAxes,'Juf (ml/min)')
app.Vp0EditField.Value=Vp0;
app.Cp0EditField.Value=Cp0;
app.Vi0EditField.Value=Vi0;
app.Ci0EditField.Value=Ci0;
app.NpointsEditField.Value=length(t);
end
% Button pushed function: BeginoptimizationButton
function BeginoptimizationButtonPushed(app, event)
t=app.t;
hct=app.hct;
juf=app.juf;
Vp0=app.Vp0;
Cp0=app.Cp0;
Vi0=app.Vi0;
Ci0=app.Ci0;
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur App Building dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!