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 Commenti

The original poster comments
I have seen that similar questions have been asked before, and want to delete my question.
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.)

Accedi per commentare.

Risposte (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 Commenti

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.
.

Accedi per commentare.

Prodotti

Release

R2020a

Richiesto:

il 1 Set 2021

Modificato:

il 14 Set 2021

Community Treasure Hunt

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

Start Hunting!

Translated by