フィルターのクリア

How to use if function MATLAB?

1 回表示 (過去 30 日間)
Cristina Muniz
Cristina Muniz 2022 年 2 月 18 日
編集済み: KSSV 2022 年 2 月 18 日
I'm writing a GUI and I want a msgbox to appear saying "Welcome Professor!" when my Professor writes down his name.
This is the code I have for now:
prompt = {'Enter Name: ', 'Enter Age: '};
dlgtitple = 'Input Values';
answer = inputdlg(prompt,dlgtitle);
name = str2num(answer{1});
age = str2num(answer{2});

回答 (1 件)

KSSV
KSSV 2022 年 2 月 18 日
編集済み: KSSV 2022 年 2 月 18 日
prompt = {'Enter Name: ', 'Enter Age: '};
dlgtitle = 'Input Values';
answer = inputdlg(prompt,dlgtitle);
name = answer{1}; % need not to convert to num, it should be a string
age = str2num(answer{2});
% proffessor = Issac Newton % give your prpfessor name
% Compare the entered name and display
if strcmpi(name,professor)
fprintf('Welcome Professor') ;
end

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by