フィルターのクリア

App Designer - "is already defined as a property"

7 ビュー (過去 30 日間)
Byron Piper
Byron Piper 2022 年 4 月 10 日
回答済み: Walter Roberson 2022 年 4 月 10 日
In the properties section of my App Designer code I'm trying to create an array of zeros using the 'zeros()' method and then set a value of that array to a value. However, for some reason this is not allowed?
Code:
x = zeros(3, 1, 8);
x(1, 1, 1) = 0;
If I hover over 'x(1, 1, 1)' I get the error message "The current use of 'x' is inconsistent with its previous use or definition" and at runtime I get the error "'x' is already defined as a property".

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 4 月 10 日
Yes, there is a reason ;-)
The properties section is not pure executable code. Each statement of the property section defines an additional variable, with an optional initialization.
You have some options:
  • you can construct an expression that returns an appropriate 3D array, using cat(3) and zeros()
  • you can define a static method or a private/ function that returns the appropriate value and call the method or function in the initialization section
  • you can leave the value uninitialized there, but initialize it in the constructor function

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by