Block averaging a large matrix

20 ビュー (過去 30 日間)
Duncan Wright
Duncan Wright 2017 年 11 月 14 日
コメント済み: Duncan Wright 2017 年 11 月 14 日
How do I go about block averaging a large matrix?? My structure 'EchoSounder1FBin1_Data' has the fields with the following dimensions:
EchoSounder1FBin1_Data.Echo11000kHzBin1_1000kHz = [7866×14400 single]
EchoSounder1FBin1_Data.Time = [1×14400 single]
EchoSounder1FBin1_Data.Range = [7866×1 single]
I would like to block average the data so I can plot it without it crashing my computer.. eg. reduce the variable size by averaging say over every 50 data points.
Thanks

採用された回答

Jan
Jan 2017 年 11 月 14 日
編集済み: Jan 2017 年 11 月 14 日
A fast C-Mex would be https://www.mathworks.com/matlabcentral/fileexchange/24812-blockmean, but currently it works with UINT8 and DOUBLEs only. But the M-File will work with a tiny modification:
if isa(X, 'double') ==> if isfloat(X)
In short it does:
X = EchoSounder1FBin1_Data.Echo11000kHzBin1_1000kHz;
S = size(X);
X = reshape(X, 50, S(1)/50, 50, S(2)/50);
Y = sum(sum(X, 1), 3) .* (1.0 / 2500); % Slightly faster than / 2500
Y = reshape(Y, S(1)/50, S(2)/50);
By the way: "Echo11000kHzBin1_1000kHz" means, that you store important data describing the measurement in the name of the variable. This is a bad design, because it impedes the automatic processing. Prefer to store the details of a measurement accessible in fields:
Data(1).Echo.Frequency = 11000;
Data(1).Echo.Bin = 1;
Data(1).Echo.Width = 1000;
Data(1).Echo.Signal = ...
Then it is much easier to apply a processing for a certain subset of data without complicated string parsing of the field names.
  1 件のコメント
Duncan Wright
Duncan Wright 2017 年 11 月 14 日
Perfect, thank you so much!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by