Using Input Function and Logic to Complete a Task
Mostra commenti meno recenti
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
Risposte (1)
Star Strider
il 26 Ott 2019
0 voti
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.
Categorie
Scopri di più su Dates and Time in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!