Have title of plot change IF edit field has text, otherwise default

조회 수: 1 (최근 30일)
Tyler
Tyler . 2022년 12월 21일
댓글: Tyler . 2022년 12월 21일
Plots created in my code default the title of the plots to the folder in which the data comes from. Usually this is what is needed, however if the user wanted to change it they could type into an edit field. How do I make the code check for text to use and if not just keep the default.
I have this but it won't change when I type into the edit field.
% Set title font size
if app.GraphTitleEditField == 0;
title(app.GraphTitleEditField.Value,'FontSize',32);
else
title(ParentFolderName,'FontSize',32);
end

채택된 답변

Bora Eryilmaz
Bora Eryilmaz 2022년 12월 21일
편집: Bora Eryilmaz 님. 2022년 12월 21일
You are comparing the edit field object itself to 0, instead of the content of the edit field. Try
if ~isempty(app.GraphTitleEditField.Value)
end
You may need char() if the Value is a string, instead of a char array:
if ~isempty(char(app.GraphTitleEditField.Value))
end
  댓글 수: 1
Tyler
Tyler 2022년 12월 21일
Oh thank you! Still learning some of the little nuances with coding.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by