Problems using structs in appdesigner as private properties

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,:);

답변 (1개)

Steven Lord
Steven Lord 2016년 10월 10일

0 개 추천

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:
  1. Make s a Dependent property whose get.s property accessor method retrieves the value of the phase property, or
  2. Declare that phase and s are properties, and possibly initialize phase in the properties block, but wait to initialize s until the constructor executes.

카테고리

도움말 센터File Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기

질문:

2016년 10월 10일

답변:

2016년 10월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by