フィルターのクリア

Binning by kilometer and creating images

1 回表示 (過去 30 日間)
Eric
Eric 2023 年 10 月 31 日
コメント済み: Emily 2023 年 11 月 2 日
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 件のコメント
DGM
DGM 2023 年 10 月 31 日
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
Emily 2023 年 11 月 2 日
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]);

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by