Hello!
I have a piece of code that runs perfectly with 10 climate data csv files (which have the same information) but with different minimum and maximum temperature values. The problem is, I have other 10 climate csv files that keep having the same problem (even though I got it from the same website and the data is the same as my first 10 files). The code is inside a for loop.
The problem says this:
I already looked at the files and they seem correct (compared to the ones that do work). I do not know how to fix it, any ideas?
Thank you!

11 comentarios

Walter Roberson
Walter Roberson el 25 de Sept. de 2021
Not really enough information for us to debug. All w ecan say is that the variable column came out empty. You need to work backwards to figure out why column is coming out empty.
Mathieu NOE
Mathieu NOE el 27 de Sept. de 2021
maybe you should share two csv files one 'good' and one 'bad' with the portion of code where you get the error
so we can test on our side
Nuria Andreu
Nuria Andreu el 3 de Oct. de 2021
Hello! I found the problem on my csv files, the years are not consistant (sometimes they skip. ex. start in 1980 then skips to 1982. This makes the code stop). The loop I have is for each year, how can I make the loop continue even if the years are not consecutive?
Thank you!!
Nuria Andreu
Nuria Andreu el 3 de Oct. de 2021
Will the "continue " work to keep running the loop?
Walter Roberson
Walter Roberson el 4 de Oct. de 2021
Certainly you could
if isempty(column); continue; end
but in that particular case, what values do you want stored in yearly_data_matrix(ind,:) ?
Nuria Andreu
Nuria Andreu el 4 de Oct. de 2021
Thank you ! I have 13 values stored in my matrix 1: record year, 2: row location begin, 3: row location end, 4: total data available (between 2 and 3), and so on.. this is how my matrix looks. It should start in year 1914 and end in year 2020, but I have a gap between year 1980-1990 (no data available) the continues on 1991. The problem is it does not continue on 1991, the code just ends. I want it to skip the dates that are not available and continue the loop until the end of year 2020.
Walter Roberson
Walter Roberson el 4 de Oct. de 2021
You are building an output matrix named yearly_data_matrix with one row for each year.
What values do you want to store into the rows for the case that the year has no associated data?
Nuria Andreu
Nuria Andreu el 4 de Oct. de 2021
Correct,
No values in particular. If there is no data available for that year, then I do not want to include it on the matrix (at the moment)
Walter Roberson
Walter Roberson el 4 de Oct. de 2021
I suggest pre-allocating the yearly_data_matrix as nan, and using if isempty(column); continue; end and then after you have constructed it, rmmissing() (though you might want to change that strategy slightly if nan can show up for other reasons.)
Nuria Andreu
Nuria Andreu el 4 de Oct. de 2021
Thank you! I will give it a try :)
Nuria Andreu
Nuria Andreu el 5 de Oct. de 2021
it worked! thank you!!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Productos

Versión

R2021a

Etiquetas

Preguntada:

el 25 de Sept. de 2021

Comentada:

el 5 de Oct. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by