フィルターのクリア

AppDesigner use of extern function and variables

2 ビュー (過去 30 日間)
prrrrr
prrrrr 2020 年 7 月 14 日
回答済み: Geoff Hayes 2020 年 7 月 15 日
hello i have written a function in Matlab:
function [cquad] = aquad(aquadv,bquadv)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
cquad = sqrt(aquadv^2+bquadv^2);
end
and now wants to output them to the Appdesigner GUI at the touch of a button.
methods (Access = public)
function c = aquad(app,aquadv,bquadv)
end
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Button
function ButtonPushed(app, event)
aquadv=app.aEditField.Value;
bquadv=app.bEditField.Value;
% c = aquad(app,aquadv,bquadv)
cEditField.Value=c
end
end
no matter how I try, I always get different flaws

採用された回答

Geoff Hayes
Geoff Hayes 2020 年 7 月 15 日
prrrrr - so long as the aquad function can be found within the MATLAB search path, then you can just call it directly from App Deisgner. You can remove the method here
methods (Access = public)
function c = aquad(app,aquadv,bquadv)
end
end
as this should just be for methods of the app so you would instead have just
methods (Access = public)
end
or I suppose you could remove this altogether. Then in the push button callback, you would do
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Button
function ButtonPushed(app, event)
aquadv=app.aEditField.Value;
bquadv=app.bEditField.Value;
cEditField.Value = aquad(aquadv,bquadv);
end
end
The above will hopefully work...

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by