diff --git a/MSF/MSF_decoder/tb/matlab/generateRandomDateTime.m b/MSF/MSF_decoder/tb/matlab/generateRandomDateTime.m new file mode 100644 index 0000000000000000000000000000000000000000..577cde7323ec16c8be4ddd8ebfb3985a7ddd523e --- /dev/null +++ b/MSF/MSF_decoder/tb/matlab/generateRandomDateTime.m @@ -0,0 +1,69 @@ +filename = "time_data.csv"; +numDates = 1000; + + % Open the file for writing + fileID = fopen(filename, 'w'); + + for i = 1:numDates + % Generate a random date and time + % Define the range for the year + minYear = 2000; + maxYear = 2100; + + % Generate a random year + year = randi([minYear, maxYear]); + + % Generate a random month + month = randi([1, 12]); + + % Determine the number of days in the generated month + if month == 2 + % Check for leap year + if mod(year, 4) == 0 && (mod(year, 100) ~= 0 || mod(year, 400) == 0) + daysInMonth = 29; + else + daysInMonth = 28; + end + elseif any(month == [4, 6, 9, 11]) + daysInMonth = 30; + else + daysInMonth = 31; + end + + % Generate a random day within the month + day = randi([1, daysInMonth]); + + % Generate a random hour (0 to 23) + hour = randi([0, 23]); + + % Generate a random minute (0 to 59) + minute = randi([0, 59]); + + % Create a datetime object + randomDateTime = datetime(year, month, day, hour, minute, 0); + + % Extract components from the datetime object + dayOfWeekName = getDayName(weekday(randomDateTime)); + + % Write the date components to the file in vertical format + fprintf(fileID, '%d\n', year); + fprintf(fileID, '%02d\n', month); + fprintf(fileID, '%02d\n', day); + fprintf(fileID, '%s\n', dayOfWeekName); + fprintf(fileID, '%02d\n', hour); + fprintf(fileID, '%02d\n\n', minute); + end + + % Close the file + fclose(fileID); + + function dayName = getDayName(dt) + % Get the day of the week as a number + dayNum = weekday(dt); + + % Define the day names + dayNames = {'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'}; + + % Get the day name + dayName = dayNames{dayNum}; +end