How would you find the missing dates. This code only gives one of the missing dates
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
In your Workspace, variable "Date" contains the date information corresponding to each data point. However, several dates may be missing from the dataset. For the house you have picked, does the dataset contain all the dates from January 1, 2018 to March 31, 2018? Write code to count the total number of missing dates, display message(s) to present ALL missing dates for the house you have picked. Use a "for loop". Some code has been provided for you to get started, fix the code as mentioned to get correct results for missing dates. Refer to zyBook Challenge Activity 18.6.2 for a similar task.
t1=datetime(2018,1,1);% January 1, 2018, the starting date. "datetime" is a MATLAB built-in function.
t2=datetime(2018,3,31);% March 31, 2018, the ending date. "datetime" is a MATLAB built-in function.
t=t1:caldays(1):t2;% Variable "t" now contains all the dates from January 1, 2018 to March 31, 2018. "caldays" is a MATLAB built-in function.
DateMissing=datetime([],[],[]);% Creating a variable to store the missing dates for later use. "datetime" is a MATLAB built-in function.
for i=1:1:1length(t)% FIX ME
if ~any(Date==t(i))
DateMissing=[DateMissing,t(i)]% FIX ME
end
end
5 comentarios
Rik
el 10 de Dic. de 2021
I have removed the flags from your questions. Feel free to do the required edit. After that, please respond to the answers you have received. Please consider marking them as accepted answer if they solved your problem (this makes them easier to find for others with a similar question), or comment with any remaining issues.
Respuestas (1)
Ver también
Categorías
Más información sobre Time Series Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!