Adding a Warning Window/Message In Matlab App Designer

조회 수: 51 (최근 30일)
Mayvel Reese
Mayvel Reese 2022년 2월 21일
댓글: Simon Chan 2022년 2월 22일
I am new to Matlab, and I am trying to figure out how I can show a warning message once either the user's input is zero or the edit field is left blank.
Do you guys know how to do it? I honestly do not know how to put warning message in Matlab App Designer. Thanks!

답변 (1개)

Simon Chan
Simon Chan 2022년 2월 21일
You may use function uialert to deliver a message to the user via a callback
Please refer to the following example and modify using App Designer.
uif = uifigure('Position',[100 100 500 250]);
edit = uieditfield(uif,'Position',[50 50 50 30],'ValueChangedFcn',{@checkValue,uif});
function checkValue(src,event,uif)
value = get(src,'Value');
if isempty(value)
uialert(uif,'Please enter a non-zero number, it is empty now','Warning','Icon','warning');
elseif str2double(value)==0
uialert(uif,'Please enter a non-zero number, it is zero now','Warning','Icon','warning');
end
end
  댓글 수: 6
Mayvel Reese
Mayvel Reese 2022년 2월 22일
It's now working. Thanks for your help!
Simon Chan
Simon Chan 2022년 2월 22일
You may accept the answer if you find it useful. Thank you.

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

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by