whats wrong with my app?

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.
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.

16 个评论

How do you call visualiseringsapp2_1.mlapp?
function startupFcn(app, app2, app3) requires two additional input arguments (app2 and app3).
@Kojiro Saito I have intentionally not sent app2 and app3 as these requires other functions to run and nobody would like to look at the problem then and I know my problem lies in visualiseringsapp2_1.
But I was unsure whether I should have both app2 and app3 as input parameters; app3 is the one where the visuaiseringsapp2_1 is called from meaning a buttom from app3 leads to visualiseringsapp2_1 . I have put app2 as an input parameter because I am using a public property from that app.
It's because "Not enough input arguments" occurs in the startupFcn of visualiseringsapp2_1, which means there is an issue in calling the visualiseringsapp2_1 from other apps.
I think app3/DisplayallresultsButtonPushed (line 1855) is the root cause.
How about changing from
visualiseringsapp2_1(app)
to
visualiseringsapp2_1(antall_soner, app)
in DisplayallresultsButtonPushed callback in app3?
antall_soner is app2 and app is app3 in this context.
but you havent written app2 in the parenthesis but antall_soner instead..?
@Kojiro Saito I think I understand it now, I will try, :)
I have done some changes following your guidelines:
  • Please see the visualiseringsapp2_1.
  • In app3 in the displayallresults button callback I have these inputs:
visualiseringsapp2_1(app.Callingapp.antall_soner,app) because antall_soner comes from app2 which is callingapp for app3.
But then I get this error when I run my apps, and the error is related to visualiseringsapp2_1:
No appropriate method, property, or field 'antall_soner' for class
'visualiseringsapp2_1'.
Error in visualiseringsapp2_1/SwitchValueChanged (line 43)
for i = 1:app.antall_soner
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 378)
Error while evaluating Switch PrivateValueChangedFcn.
>>
"No appropriate method, property, or field 'antall_soner' for class 'visualiseringsapp2_1'." means there is no difinition of antall_soner in visualiseringsapp2_1.mlapp.
Could you confirm app.antall_soner exists in the Public Property in visualiseringsapp2_1.mlapp?
@Kojiro Saito Are you sure that I have to write app.antall_soner in the public proberty field in visualiseringsapp2_1 and not antall_soner. As I have understood you declare the variables there and use app. in front of them when you use the variables in the callbacks..
I'm a bit confused.
in app3, you are calling the following function.
visualiseringsapp2_1(app.Callingapp.antall_soner,app)
in this context, visualiseringsapp2_1 is app1, app is app3, but app.Callingapp is as app3 in app2, so how do you define app.Callingapp inside app3?
@Kojiro Saito I am sorrry but I didnt understand your question..?
antall_soner is a variable that belongs to app2 which is callingapp in app3. Thats why I wrote app.callingapp.antall_soner as one of my input, and app represents app3 as you also wrote..
But I am getting error
I think now I understand what you meant,
in the startup function for app3, I have this code:
function startupFcn(app, app2)
app.Callingapp = app2;
end
Maybe the error lies in the way I have defined antall_soner in the for loop in visualiseringsapp2_1..?
I have written for i = 1:app.antall_soner
and the error is :
No appropriate method, property, or field 'antall_soner' for class
'visualiseringsapp2_1'.
Error in visualiseringsapp2_1/SwitchValueChanged (line 43)
for i = 1:app.antall_soner
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 378)
Error while evaluating Switch PrivateValueChangedFcn.
I am not sure why in app3, the startup would be.
function startupFcn(app, app2)
app.Callingapp = app2;
end
Did you mean app3 is calling visuaiseringsapp2_1? I am not clear why app2 is an input argument of app3.
@Kojiro Saito app3 is leading to visualiserignsapp2_1 yes and app2 leads to app3 by a push button that is why it is an input argument there..
@Muazma Ali I understand you want to execute app2 Push Button -> app3, then, app3 Push Button -> visualiserignsapp2_1. Is it correct?
Muazma Ali
Muazma Ali 2024-3-14
编辑:Muazma Ali 2024-3-14
@Kojiro Saito Yes, each app leads to the other.
And I want to use the public property called antall_soner from app2 in visualiseringsapp2_1

请先登录,再进行评论。

回答(1 个)

I think the following will work.
app2.mlapp
Set public properties.
properties (Access = public)
antall_soner
end
and button callback is the following.
function App2ButtonPushed(app, event)
app3(app)
end
app3.mlapp
Set private properties.
properties (Access = private)
Callingapp
end
and starup function is as follows.
function startupFcn(app, app2)
app.Callingapp = app2;
end
and Button Push Callback will be.
function App3ButtonPushed(app, event)
visualiseringsapp2_1(app.Callingapp, app)
end
visualiseringsapp2_1.mlapp
Set public properties.
properties (Access = public)
Callingapp
app2
end
and starup function is as follows.
function startupFcn(app, app2, app3)
app.Callingapp = app3;
app.app2 = app2;
app.antall_soner = app2.antall_soner;
end

2 个评论

@Kojiro Saito Hi again! :)
I dont understand the purpose of writing
app.app2 = app2;
app.antall_soner = app2.antall_soner;
Please explain, :)
In addition to what you wrote I declared antall_soner as a public property in visualiseringsapp2_1. Because I was getting error again saying unrecogninsed variable antall_soner for class of visualiseringsapp2_1

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by