Size of the left side

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 Comments

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.
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
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!!
Will the "continue " work to keep running the loop?
Certainly you could
if isempty(column); continue; end
but in that particular case, what values do you want stored in yearly_data_matrix(ind,:) ?
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.
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?
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)
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.)
Thank you! I will give it a try :)
it worked! thank you!!

Sign in to comment.

Answers (0)

Products

Release

R2021a

Tags

Asked:

on 25 Sep 2021

Commented:

on 5 Oct 2021

Community Treasure Hunt

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

Start Hunting!