So I have matlab code to find maximum wave height (Hs) with 2 condition: by direction and by year like this photos below.
TableHm2 = readtable('02_Output HsTs.xlsx');[r,rn] = findgroups(TableHm2(:,1));[c,cn] = findgroups(TableHm2(:,6));out = accumarray([r,c],TableHm2.Hs,[],@max);Tout = array2table([rn.Tahun,out],'VariableNames',[{'Year'};cn.Arah2]);
But when I was running, it didnt work. The error says:
Error using accumarrayFirst input SUBS must contain positive integer subscripts.Error in coba3 (line 4)out = accumarray([r,c],TableHm2.Hs,[],@max);
So, how should I do? Thanks before
Best Answer