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 Kommentare

Walter Roberson
Walter Roberson am 6 Sep. 2021
Bearbeitet: Walter Roberson am 14 Sep. 2021
The original poster comments
I have seen that similar questions have been asked before, and want to delete my question.
Walter Roberson
Walter Roberson am 6 Sep. 2021
Bearbeitet: Walter Roberson am 14 Sep. 2021
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.)

Melden Sie sich an, um zu kommentieren.

Antworten (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 Kommentare

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.
.
My pleasure!
Without having the data to work with, I cannot offer any specific solutions. I am not even certain what to suggest.
.

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2020a

Gefragt:

am 1 Sep. 2021

Bearbeitet:

am 14 Sep. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by