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
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:
- 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.
カテゴリ
ヘルプ センター および File Exchange で Call Java from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!