Creating empty ui control component

조회 수: 5 (최근 30일)
Bruno Pilon
Bruno Pilon 2020년 12월 22일
댓글: Bruno Pilon 2020년 12월 22일
When using appdesigner, I want to initialize a property as an array of labels and text area
properties (Access = private)
comp_ui_obj
end
function startupFcn(app)
app.comp_ui_obj(1) = app.CompLabel;
% 2..n assignments here
end
The problem is that the declaration of comp_ui_obj is by default double. Because of this app.comp_ui_obj(1) will contain a double instead of a matlab.ui.control object.
So, it seems that app.comp_ui_obj needs to be initialized as an empty matlab.ui.control object before the assignment.
With some classes, the empty function can be used for this (ex: uint8.empty). However, matlab.ui.control.empty does not work.
So, how do we initialize an empty ui control in appdesigner? How do we initialize a vector of empty elements?
  댓글 수: 1
Cris LaPierre
Cris LaPierre 2020년 12월 22일
Could you provide more detail on why you are wanting to do this? What is the need driving this workflow?

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

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 12월 22일
Try setting your property to an empty Label class using the following
comp_ui_obj = matlab.ui.control.Label.empty
  댓글 수: 1
Bruno Pilon
Bruno Pilon 2020년 12월 22일
This is exactly what I was looking for. I was missing the capital L of Label. Thank you!

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

추가 답변 (1개)

Bruno Pilon
Bruno Pilon 2020년 12월 22일
I found one way to initialize the ui control variable:
dummy_obj = uilabel(app.UIFigure);
app.comp_ui_obj = repelem(dummy_obj,nb_of_objects);
Then, the assignments work as app.comp_ui_obj already contains ui objects.

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by