Hello, i have a [365, 24] table reporting values per hour for each day of the year.
How can I assign days names to all 365 rows ('Monday','Tuesday'...) without writing 365 names with 'RowNames'?

1 Kommentar

Stephen23
Stephen23 am 4 Dez. 2023
There is only a small chance that some random year will start on a Monday.
To obtain the correct days of the week you should use DATETIME.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Matt J
Matt J am 4 Dez. 2023
Bearbeitet: Matt J am 4 Dez. 2023

0 Stimmen

The row names of a table cannot be non-unique, so having the names of the 7 days of the week repeat 52 times would not generate legitimate input for RowNames. However, you can make a string column of the days of the week as below and prepend it to your table as an additional (but ordinary) table column.
names=repmat(["Monday";"Tuesday";"Wednesday";"Thursday";"Friday";"Saturday";"Sunday"],52,1);
names=[names;names(1)]
names = 365×1 string array
"Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" "Monday" "Tuesday"

Weitere Antworten (0)

Kategorien

Produkte

Version

R2022b

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by