ZijieZhaoMMHW / m_mhw1.0

A MATLAB toolbox to detect and analyze marine heatwaves (MHWs).
GNU General Public License v3.0
42 stars 16 forks source link

an_example #15

Open Marina-red opened 3 years ago

Marina-red commented 3 years ago

Hello! I'm trying to run an_example.m on matlab 2014b And there is an error: Error using >= Matrix dimensions must agree.

Error in detect (line 176) data_thre=num2cell(temp_clim(:,:,any(ind_fake'>=(ind_fake(fake_doy == i)-vWindowHalfWidth) & ind_fake' <= (ind_fake(fake_doy ==i)+vWindowHalfWidth),2)),3);

Error in an_example (line 28) [MHW,mclim,m90,mhw_ts]=detect(sst_full,datenum(1982,1,1):datenum(2016,12,31),datenum(1982,1,1),datenum(2005,12,31),datenum(1993,1,1),datenum(2016,12,31));; %take about 30 seconds.

What it can be?

pittwolfe commented 3 years ago

I get a similar error on the same line using Matlab 2018a, except my error is The logical indices in position 3 contain a true value outside of the array bounds and it occurs for i = 366. It seems like its trying to read a time outside the bounds of my input data, but the climatology range I have it is well inside my data. My climatological range is Jan 1 1990 to Dec 31 1995, which contains a leap year.

Marina-red commented 3 years ago

In version 2019b my error disappeared

pittwolfe commented 3 years ago

It turns out that my problem was that my "time" variable had days and hours in it rather than just full days, which confused the search. Might be worth putting in a line to round the times to whole days to avoid this in the future.

ZijieZhaoMMHW commented 3 years ago

@pittwolfe Thanks for the suggestion. We would make the change in the future.