Binning by kilometer and creating images
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
interval = 15; %change this to change the interval displayed on the diagram
time_start = datenum(year_start, month_start, day_start, hour_start, min_start);
time_end = datenum(year_end, month_end, day_end, hour_end, min_end);
latedges = -90:interval:90;
lonedges = -180:interval:180;
nlatbins = numel(latedges)-1;
nlonbins = numel(lonedges)-1;
latbin = discretize(lat_cg_all, latedges);
lonbin = discretize(long_cg_all, lonedges);
bincounts = accumarray([latbin(:), lonbin(:)], energy_cg_all(:), [nlatbins, nlonbins]);
imagesc(latedges, lonedges, bincounts); colorbar(); title('Bin Test'); set(gca, 'YDir', 'normal')
I put the code above. How can I make this bin kilometers instead of long/lat?
Also, I've been experimenting, but I haven't been able to figure out how I can set a time interval for the data that I am binning (for example, instead of binning all the data, I can just select 15 minutes of data). Does anyone know how I could do this?
3 Kommentare
DGM
am 31 Okt. 2023
You can use distance() and deg2km() if you have mapping toolbox. Alternatively, you can do the conversion the hard way. There are answers that cover both here:
Emily
am 2 Nov. 2023
Are energy_cg_all, latbin, and lonbin all 1-d vectors whose index corresponds to a time? If so, then to just select 15 minutes of data you need to convert the start and end times of the 15 minutes into the index values that correspond to the start and end times. Then your accumarray function can become:
bincounts = accumarray([latbin(time_start_index:time_end_index), lonbin(time_start_index:time_end_index)], energy_cg_all(time_start_index:time_end_index), [nlatbins, nlonbins]);
If instead they are 2-d or higher dimension matrices (they are functions of time and some other parameter or label) then you can select the data you need and create a new variable to put into accumarray:
latbin_myinterval = latbin(time_start_index:time_end_index,:); % This assumes time index is the first of 2 indices
lonbin_myinterval = lonbin(time_start_index:time_end_index,:);
energy_cg_myinterval = energy_cg_all(time_start_index:time_end_index,:);
bincounts = accumarray([latbin_myinterval(:), lonbin_myinterval(:)], energy_cg_myinterval(:), [nlatbins, nlonbins]);
Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!