Block averaging a large matrix
20 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!