How to access properties of objects instantiated between different classes in multi-window matlab app designer

3 views (last 30 days)
I'm creating an application where the main app, after performing some functions and storing some data, calls app.2 or app.aux. However, to perform a certain function in app.2 I need a result (artificial neural) created in the main app.´
The neural network is a public property in the main app
app.2 does not display the neural network created in the main app as properties when it starts. Can someone help me?

Accepted Answer

Walter Roberson
Walter Roberson on 6 Aug 2022
app2 and app aux each have constructor methods. Change the constructors to accept an option parameter which is the handle of the calling app. Then when you invoke them, pass in app from the first routine.
If it does not permit you to change the constructor, then have the constructor just create the new app and return its handle. Then add a method that accepts the handle to the calling app and stores it away and does whatever real work is desired.
  4 Comments
Arlan Pacheco Figueiredo
Arlan Pacheco Figueiredo on 9 Aug 2022
Hello
I finally got the code right.
I created a Calling property in app aux.
properties (Access = private)
Calling
And I started the app aux with the following code.
% Code that executes after component creation
function startupFcn(app, app_RNA, net_SOLD)
app.Calling = app_RNA; % carregar dados do app main
Then I inserted the following code in the "simulate" button
app.D1 = [app.Is; app.Us; app.Vs; app.Es;]%with some error
app.Simul = sim(app.Calling.net_SOLD,app.D1)
When the data is manually entered with the matrix D1= [170; 10; 8 ;6;] (for example), I get the simulated response by the neural network.
However, I'm having difficulties to assemble the D1 array, because it is assembled from the EditFieldNumeric buttons and when I assemble the array with the code.
app.D1 = [app.Is; app.Us; app.Vs; app.Es;]
where app.Is.. app. Us.. are the values of the fields entered by the user, and the matrix D1 does not assemble an array and the error appears.
"Error using network/sim (line 248). Inputs is not a matrix or cell array."
I request a "test" button to send me the D1 matrix created by the numeric field data and I have the following response.
value =
4×1 NumericEditField array:
NumericEditField (170)
NumericEditField (10)
NumericEditField (8)
NumericEditField (6)
I would need the answer to be:
value =
170
10
8
6
Can you help me?

Sign in to comment.

More Answers (0)

Categories

Find more on Software Development Tools in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!