Using Input Function and Logic to Complete a Task
Show older comments
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
Answers (1)
Star Strider
on 26 Oct 2019
0 votes
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.
Categories
Find more on Dates and Time in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!