Using Input Function and Logic to Complete a Task
Mostrar comentarios más antiguos
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
Respuestas (1)
Star Strider
el 26 de Oct. de 2019
0 votos
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.
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!