Problem with properties in App Designer.

Hello. I need help with "properties" in App Designer. I have some trouble with realization the method of symmetrical components.
properties (Access = public)
a = -.5 + sqrt (3) / 2 * j; % Phase-shift operator
     F = [1 a^2 a; 1 a a^2; 1 1 1]; % Matrix Fortescue
end
Message: "Invalid default value for property 'F' in class 'App1': Undefined function or variable 'a'."
If I replace "a" with "app.a" in the Matrix Fortescue.
Message: "Invalid default value for property 'F' in class 'App1': Undefined variable "app" or class "app.a"."

답변 (1개)

Steven Lord
Steven Lord 2017년 7월 28일

0 개 추천

Since you're probably not going to want a and F to change based on the state of your app, make them Constant properties, properties with the Constant attribute.

댓글 수: 6

properties (Constant)
a = 1;
b = a+1;
end
function ButtonPushed(app, event)
app.EditField.Value = app.EditField.Value + app.b;
end
Message: Invalid default value for property 'b' in class 'App1': Undefined function or variable 'a'.
Steven Lord
Steven Lord 2017년 7월 29일
You want to define the property app.b in terms of the property app.a, not a variable a. In the first example on the documentation page to which I directed you, note how property NamedConst.D is defined in terms of property NamedConst.R and not on a variable named R.
New
New 2017년 7월 29일
편집: New 2017년 7월 29일
1 example: Invalid default value for property 'F' in class 'App1': Undefined variable "app" or class "app.a".
properties (Access = public)
a = -.5 + sqrt (3) / 2 * j; % Phase-shift operator
F = [1 app.a^2 app.a; 1 app.a app.a^2; 1 1 1]; % Matrix Fortescue
end
2 examle: Just replace 'app.a' with value 'a' in 'F'.
properties (Access = public)
a = -.5 + sqrt (3) / 2 * j;
F = [1 (-.5 + sqrt (3) / 2 * j)^2 -.5 + sqrt (3) / 2 * j; 1 -.5 + sqrt (3) / 2 * j (-.5 + sqrt (3) / 2 * j)^2; 1 1 1];
end
3 example: Add startup function.
properties (Access = public)
a = -.5 + sqrt (3) / 2 * j;
F;
end
...
function startupFcn(app)
app.F = [1 app.a^2 app.a; 1 app.a app.a^2; 1 1 1];
end
2 and 3 example work true. But how define property on other properties in the first case? And what difference between 3 and 1 case?
Steven Lord
Steven Lord 2017년 7월 29일
The name of your app class is App1? Then you need App1.a. In general if your app class was named CLASSNAME, you would use CLASSNAME.a.
New
New 2017년 7월 29일
편집: New 2017년 7월 29일
No, prefix does not depend on the name of the application or classname.
Steven Lord
Steven Lord 2017년 7월 29일
That is correct IF you're referring to a property of an instance of the class. A Constant property can be accessed even if you don't have an instance of the class, and the way you do that is by using the name of the class.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

질문:

New
2017년 7월 28일

댓글:

2017년 7월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by