Using Input Function and Logic to Complete a Task
显示 更早的评论
As a part of a project, I am trying to use the input function to enter a day of the week and if said day is on the weekend it results in one output dialogue, if it is a weekday it is a separate output dialogue. Any help on how to format this correctly? I'll put what I currently have below.
% Day of week using the input function
clear
clc
day_of_week = input('What is your favorite day of the week? \n','s');
if (day_of_week == Saturday || day_of_week == Sunday );
disp('Have a nice weekend!')
else
disp('Good luck in your class lectures and studies.');
end
回答(1 个)
Star Strider
2019-10-26
0 个投票
Second, if you choose the string output from weekday (or just generic strings), use the strcmp function to compare the strings.
That should get you started.
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!