how to clear label area in each if/elseif loop ?

조회 수: 3 (최근 30일)
Ali Deniz
Ali Deniz 2022년 6월 21일
댓글: Image Analyst 2022년 7월 3일
function UITableCellSelection(app, event)
global t
indices = event.Indices;
n=indices(1);
% Information and the Images of the Missiles
if strcmp(t.System{n},"MIM-23A HAWK")
cla(app.UIAxes)
imshow("MIM_23A_HAWK.jpg","Parent",app.UIAxes)
MsgString = {'Raytheon tarafından geliştirilen sistem'};
WrapString=textwrap(MsgString, 70);
uilabel(app.UIFigure,"Text",WrapString,"Position",[531 17 368 279])
elseif strcmp(t.System{n},"CAMM")
cla(app.UIAxes)
imshow("CAMM.jpg","Parent",app.UIAxes)
MsgString = "Common Anti-air Modular Missile - CAMM ya da deniz ortamında kullanılan Sea Ceptor";
WrapString=textwrap(MsgString, 70);
uilabel(app.UIFigure,"Text",WrapString,"Position",[531 17 368 279])
elseif strcmp(t.System{n},"CAMM-ER")
cla(app.UIAxes)
imshow("CAMM_ER.jpg","Parent",app.UIAxes)
MsgString = "Orta menzilli karatabanlı hava savunma ";
WrapString=textwrap(MsgString, 65);
uilabel(app.UIFigure,"Text",WrapString,"Position",[531 17 368 279])
When I select the CAMM-ER after the CAMM, the texts in the label text area is shown like that. How can I clear the label text area before the second information? Thank you.

답변 (2개)

Image Analyst
Image Analyst 2022년 6월 21일
Can't you just do
app.UIFigure.Text = '';
  댓글 수: 2
Ali Deniz
Ali Deniz 2022년 6월 21일
It gives the error "Unrecognized property 'Text' for class 'matlab.ui.Figure' " . I use Matlab R2019b version. I also tried " app.Label.Value = ''; ". It gives the error "Unrecognized property 'Value' ". Thank you.
Image Analyst
Image Analyst 2022년 7월 3일
If your static text label is not called UIFigure, then use the actual name of the static text label or edit text field. Let's say the one edit text field near Guidance is called edtGuidance. Then do
app.edtGuidance.Text = 'blah blah blah whatever';

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


Voss
Voss 2022년 7월 3일
Calling uilabel creates a new label component. Any other label components that already exist are unaffected by the creation of a new label. Therefore, if you want the new label component to replace the old one(s), you would delete the old one(s) when the new one is created.
However, you can avoid having to do all that by using one label the whole time and just update its Text property when needed:
app.Label.Text = WrapString;

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by