whats wrong in the for loop in my app?
3 次查看(过去 30 天)
显示 更早的评论
type visualiseringsapp2_1.mlapp
I have a for loop in visualiseringsapp 2_1 , there is something wrong in it I think
I am gettin this error message when I run the app:
Error using visualiseringsapp2_1/startupFcn (line 23)
Not enough input arguments.
Error in visualiseringsapp2_1 (line 115)
runStartupFcn(app, @(app)startupFcn(app, varargin{:}))
Error in app3/DisplayallresultsButtonPushed (line 1855)
visualiseringsapp2_1(app)
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 335)
Error while evaluating Button PrivateButtonPushedFcn.
Dot indexing is not supported for variables of this type.
Error in visualiseringsapp2_1/SwitchValueChanged (line 42)
for i = 1:app.Callingapp.antall_soner
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 378)
Error while evaluating Switch PrivateValueChangedFcn.
.......
I have declared app2 as the input argument in my startup for visualiseringsapp2_1 because it is using the public property from app2 (called antall_soner), and the callingapp is app 3 . ( meaning the visualiseringsapp2_1 is called from app3), as you can see.
0 个评论
回答(1 个)
Eric Delgado
2024-4-1
My first piece of advice is: try to assign meaningful names to your applications. Names like 'app2', 'app3', and 'visualiseringsapp2_1' are definitely not helpful! :)
So, if I understood correctly, you're calling 'visualiseringsapp2_1' from 'app3', and you're trying to pass the handles of 'app2' and 'app3' to 'visualiseringsapp2_1'. Inside 'visualiseringsapp2_1', you have a startup function like this:
startupFcn(app, app2, app3)
The error messages was: "Not enough input arguments."
When you push a button, in "app3", you are calling:
visualiseringsapp2_1(app)
But look... you are not passing two arguments, but one! If you intend to keep 'app2' and 'app3' as arguments for your 'visualiseringsapp2_1' app, in this order, then your call (inside 'app3') should look something like this:
visualiseringsapp2_1(app.app2Handle, app)
Notice that since you want to pass the handle of 'app2' to 'visualiseringsapp2_1', it's a good idea to store its handle as a property of 'app3'. Below changes that you have to make...
%% Changes in "app3.mlapp"
properties (Access = public)
App2Handle
end
% DisplayallresultsButtonPushed
visualiseringsapp2_1(app.App2Handle, app)
%% Changes in "visualiseringsapp2_1.mlapp"
% Create a property for each handle...
properties (Access = public)
App2Handle
App3Handle
end
function startupFcn(app, app2, app3)
app.App2Handle = app2;
app.App3Handle = app3;
end
% And replace app.Callingapp.antall_soner for app.App2Handle.antall_soner
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!