Borrar filtros
Borrar filtros

How to create a function, that outputs Weekdays on given date?

3 visualizaciones (últimos 30 días)
Mihir Rathod
Mihir Rathod el 1 de Nov. de 2021
Comentada: Cris LaPierre el 12 de Mzo. de 2022
hello everyone,
basically i have to create my own function, which gives me the weekday when i give date. for exp in this format :
input : 26,06,2021
output : Date = 26,06,2021
Day = Saturday
I am trying to write it, but i am not getting any further, i would really appreciate it, if anyone can help me.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 1 de Nov. de 2021
Convert the date to a datetime, and use the day function to return the day name.
D = datetime(2021,06,26);
out = day(D,'name')
out = 1×1 cell array
{'Saturday'}
  4 comentarios
Dianela Jimenez Ramirez
Dianela Jimenez Ramirez el 12 de Mzo. de 2022
Hi Cris, your comment has been very helpful! I´m wondering if there is a way to show only day and hide the phrase in the output out = 1×1 cell array. Thank you!
Cris LaPierre
Cris LaPierre el 12 de Mzo. de 2022
Use the function disp
D = datetime(2021,06,26);
out = day(D,'name');
disp(out{1})
Saturday
ans = 'Saturday'

Iniciar sesión para comentar.

Categorías

Más información sobre Calendar en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by