Block averaging a large matrix
조회 수: 10 (최근 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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!