Mean error for binned values

7 Ansichten (letzte 30 Tage)
Karel Starý
Karel Starý am 18 Jun. 2021
Kommentiert: Karel Starý am 4 Aug. 2021
Hello guys!
I have a data sets with the measurements and GPS coordinates, where the values were measured. For this data set I am using a bins of 10 meters and 20 meters. I am calculating a means from the values.
[latbin, lonbin] = hista(w_files{ii}.lat,w_files{ii}.lon,0.0001);% bin at 10x10m,hista binning + computing bins
[w_files{ii}.latEq, w_files{ii}.lonEq] = grn2eqa(w_files{ii}.lat,w_files{ii}.lon);% Convert coordinates to equidistant cartesian coordinates
[latbinEq, lonbinEq] = grn2eqa(latbin, lonbin);% Convert coordinates to equidistant cartesian coordinates
dist = pdist2([w_files{ii}.lonEq,w_files{ii}.latEq],[lonbinEq, latbinEq]);% Compute distance between each coordinate and each bin-center
[~, w_files{ii}.bin10] = min(dist,[],2);% Add bin ID numbers to table
%% making a medians from bin variable values
time_b10 = splitapply(@median,w_files{ii}.time, w_files{ii}.bin10);
lon_b10 = lonbin;
lat_b10 = latbin;
lon_b10 = splitapply(@nanmedian,w_files{ii}.lon, w_files{ii}.bin10);
lat_b10 = splitapply(@nanmedian,w_files{ii}.lat, w_files{ii}.bin10);
sinr_lte_b10 = splitapply(@nanmedian,w_files{ii}.sinr_lte, w_files{ii}.bin10);
cinr_lte_b10 = splitapply(@nanmedian,w_files{ii}.cinr_lte, w_files{ii}.bin10);
rsrp_lte_b10 = splitapply(@nanmedian,w_files{ii}.rsrp_lte, w_files{ii}.bin10);
prb_dl_lte_b10 = splitapply(@nanmedian,w_files{ii}.prb_dl_lte, w_files{ii}.bin10);
prb_ul_lte_b10 = splitapply(@nanmedian,w_files{ii}.prb_ul_lte, w_files{ii}.bin10);
bler_dl_lte_b10 = splitapply(@nanmedian,w_files{ii}.bler_dl_lte, w_files{ii}.bin10);
bler_ul_lte_b10 = splitapply(@nanmedian,w_files{ii}.bler_ul_lte, w_files{ii}.bin10);
tp_mac_d_lte_b10 = splitapply(@nanmedian,w_files{ii}.tp_mac_d_lte, w_files{ii}.bin10);
tp_mac_u_lte_b10 = splitapply(@nanmedian,w_files{ii}.tp_mac_u_lte, w_files{ii}.bin10);
tp_pdsch_lte_b10 = splitapply(@nanmedian,w_files{ii}.tp_pdsch_lte, w_files{ii}.bin10);
tp_pusch_lte_b10 = splitapply(@nanmedian,w_files{ii}.tp_pusch_lte, w_files{ii}.bin10);
This was working perfectly for me for last few weeks but now I got a data set where I am unable to use this 10x10 bin. It gives me those two errors:
Error using splitapply (line 111)
For N groups, every integer between 1 and N must occur at least once in the vector of group numbers.
Error in b10 (line 37)
time_b10 = splitapply(@median,w_files{ii}.time, w_files{ii}.bin10);
The odd think is that in this particular case I have two datasets which has same number of rows and same variables just the measured values are different. One works as intended and second one not.
Same If I try to run 20x20 bin its works flawlessly but when I run the 10x10m variation it gets stuck.
Only difference in the codes is naming ( xxx_B10 / xxx_b20) and this one line of code:
[latbin, lonbin] = hista(w_files{ii}.lat,w_files{ii}.lon,0.0001);% bin at 10x10m,hista binning + computing bins
[latbin, lonbin] = hista(w_files{ii}.lat,w_files{ii}.lon,0.0004);% bin at 20x20m,hista binning + computing bins
If you wanna know a bit more of my code please folow: https://www.mathworks.com/matlabcentral/answers/832518-geographical-binning-and-evaluation-of-results?s_tid=mlc_ans_email_view#comment_1530173
Will appreciate any idea why I am experiencing this difficulties or how to solve them. Please try to explain the ideas as thorough as possible, because I think that I might be dumb.

Antworten (1)

Steven Lord
Steven Lord am 18 Jun. 2021
Rather than calling splitapply multiple times, I'd call groupsummary once and have it operate on multiple data variables at once. Or you might need two groupsummary calls, once with @median to operate on the times and once with @(x) median(x, 'omitnan') to operate on the other variables, if the missing data in the times is important. That way you only have to specify the groupbins once.
  1 Kommentar
Karel Starý
Karel Starý am 4 Aug. 2021
Can you please give me a specific example how to proceed in my case because I read all info around the groupsummary and I did not understood it.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Preprocessing finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by