Problems using structs in appdesigner as private properties
Afficher commentaires plus anciens
I have a problem when trying to get some variables out of a struct in order to use them as a property in my app. I tried the following:
properties (Access = private)
%%load results
phase = coder.load('phase.mat');
%%extract variables
s = phase.phase.StateGrid.Values(1,:);
The following error appears:
Undefined variable "phase" or class "phase.phase.StateGrid.Values".
If I use exactly the same lines in Matlab the code works. I also tried the following, but this did not help neither:
properties (Access = private)
%%load results
phase = coder.load('phase.mat');
%%extract variables
s = app.phase.phase.StateGrid.Values(1,:);
Réponses (1)
Steven Lord
le 10 Oct 2016
0 votes
You're assuming that the code to initialize the phase property executes before the code to initialize the s property. I'm not sure that assumption is safe to make. I would probably:
- Make s a Dependent property whose get.s property accessor method retrieves the value of the phase property, or
- Declare that phase and s are properties, and possibly initialize phase in the properties block, but wait to initialize s until the constructor executes.
Catégories
En savoir plus sur Call Java from MATLAB 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!