필터 지우기
필터 지우기

Editing Properties in gui-code

조회 수: 1 (최근 30일)
Elia
Elia 2013년 12월 19일
댓글: Image Analyst 2013년 12월 19일
i want to change the lable of the axes , but i don't know where i must write x/y-lable command in the gui-code ? as a general rule , where can i edit the properties of an object in the code .

채택된 답변

Image Analyst
Image Analyst 2013년 12월 19일
Whenever you want to change the text label, just put this code
yourString = sprintf('The value = %f', someDoubleVariable); % or whatever you want.
set(handles.textLabel, 'String', yourString); % or whatever tag you have instead of "textLabel"
drawnow; % Use draw now if in a fast loop.
It can go in whatever callback or loop you want, basically whenever and wherever you want to change the text on the label control.
  댓글 수: 2
Elia
Elia 2013년 12월 19일
편집: Elia 2013년 12월 19일
can you give me an example for editing the XLable or XLim ?
Image Analyst
Image Analyst 2013년 12월 19일
% Create sample data.
x = -50 : 50;
y = sind(x*30);
plot(x, y, 'LIneWidth', 3);
grid on;
% Make x axis go from -10 to +30
% instead of -50 to +50:
xlim([-10, 30]);
% Give a label to the x axis:
xlabel('This is the x axis',...
'FontSize', 20,...
'FontWeight', 'bold',...
'Color', [.7, 0.3, 0.9]);

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

추가 답변 (1개)

David Sanchez
David Sanchez 2013년 12월 19일
You can use the Property Inspector if you use GUIDE (right click on the object whose properties you want to modify, select Property Inspector, look for the field to change in the emerging window).
Otherwise, you have to use set and get commands to perform changes in any object of your GUI.
  댓글 수: 3
Sean de Wolski
Sean de Wolski 2013년 12월 19일
Do it in the OutputFcn.
You can run:
inspect(get(handles.axes1,'XLabel'));
To pull up the xlabel in the inspector. axes1 is the 'Tag' of the axes you care about.
Elia
Elia 2013년 12월 19일
it works with inspect command , but it seems like every time i run the code it will appear ?
i tried this , but it doesn't work
myname = get(handles.axes1,'XLabel'); set(handles.axes1,'XLabel',myname);

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by