How do I retrieve data from multiple different days using a for loop?
显示 更早的评论
I have a function that can retrieve data from the date one wants to look at. I want to make a plot of the temperature as a function of time for the whole year.
function [lon, lat, t, z, T, S, u, v] = read_data_set (yr, mon, dy)
I was wondering how I could use this function to run through every day from 2015-08-29 to 2017-07-31. I have tried to make a for loop, but i'm currently stuck, since it is three different input arguments.
2 个评论
Walter Roberson
2021-9-6
编辑:Walter Roberson
2021-9-14
The original poster comments
I have seen that similar questions have been asked before, and want to delete my question.
Walter Roberson
2021-9-6
编辑:Walter Roberson
2021-9-14
Original poster:
Sorry, out of respect for the efforts of the volunteers, Questions that have an reasonable attempt at an Answer are only deleted under unusual circumstances (such as if the question was abusing the system.)
回答(1 个)
Star Strider
2021-9-1
I have no idea what the data are (and there could be ways to make this more efficient).
Making a few assumptins, I would create the loop as:
lon = NaN(NumDays,1); % Preallocate The Other Outputs Similarly
for k = 1:NumDays
[lon(k), lat(k), t(k), z(k), T(k), S(k), u(k), v(k)] = read_data_set (yr(k), mon(k), dy(k));
end
The resulting vectors should have the information you want.
.
2 个评论
Star Strider
2021-9-1
I have no idea what the data are. (I thought that they were matrix data of specific values, so that a for loop could go through the matrix to return the necessary values.) I cannot improve on the solution I already posted.
If the data are in a table or timetable, retrieving data for specific dates and times or over a range of them is straightforward using logical indexing.
.
Star Strider
2021-9-2
My pleasure!
Without having the data to work with, I cannot offer any specific solutions. I am not even certain what to suggest.
.
类别
在 帮助中心 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!