Passing input arguments into a function in Matlab AppDesigner
Afficher commentaires plus anciens
Hey guys,
I'm new to Matlab AppDesigner (using 2018b). I have a external m-file function which I want to call in Matlab AppDesigner, pass input into it and obtain the output. I declared the variables in the Property section and functions in the Function section.
Below is the code snippet for my Function section, where I define the functions:
methods (Access = public)
function [meanErr,maxErr,timerVal,hmid2,hamid2] = validate(app)
[app.meanErr,app.maxErr,app.timerVal,app.hmid2,app.hamid2] = ...
validateD2Q9(app.N_iter,app.len,app.wid,app.lx,app.ly,app.Cs,app.rho,app.tau,app.depth,app.A);
end
end
Then, I called the function validate(app) in pushbuttoncallback:
function RunButtonPushed(app, event)
[app.meanErr,app.maxErr,app.timerVal,app.hmid2,app.hamid2] = validate(app);
plot(app.UIAxes,app.hmid2,'LineStyle',':','Color','b');
plot(app.UIAxes,app.hamid2,'LineStyle','-','Color','r');
end
When I run the GUI, I get the following error:
Error using linspace (line 22)
Inputs must be scalars.
Error in validateD2Q9 (line 14)
X = linspace(0,len,lx); Y = linspace(0,wid,lx); %coordinate of each lattice
Error in airylbm2d_app/RunButtonPushed (line 109)
[app.meanErr,app.maxErr,app.timerVal,app.hmid2,app.hamid2] = validate(app);
Previously if I run the m-file directly, everything works fine. Why am I getting this error? Is it because of some syntax mistakes I've made?
Cheers and thanks
Réponses (0)
Catégories
En savoir plus sur Startup and Shutdown 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!