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!