griddata (averaging instead of interpolation)
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have many raw data points of a pipe surface that i scanned with a 3D scanner. the amount of points is about 4 times as much as my intended grid points. I would like to average the data (about a small cell) at a every specific grid point (to lessen the scanner noise), instead of using matlab 'linear' 'cubic' or 'nearest neighbor'.
How can i do so, is there better function than griddata that i can use?
thank you
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 18 Feb. 2011
As I understood you have 2D data r depending of theta and z (and not 3D).
theta = rand(100000,1)*2*pi;
z = rand(100000,1)*4-2;
r = 1+theta.*exp(-theta.^2-z.^2);
r = r+0.05*randn(size(r));
thetai=linspace(0,2*pi,33);
zi = linspace(-2,2,33);
% FEX: http://www.mathworks.com/matlabcentral/fileexchange/23897-n-dimensional-histogram
tz = [theta(:) z(:)];
[~, ~, ~, loc] = histcn(tz, thetai, zi);
r_avg = accumarray(loc, r(:), [length(thetai) length(zi)]) ./ ...
accumarray(loc, 1, [length(thetai) length(zi)]);
figure(1);
subplot(1,2,1);
plot3(z,theta,r,'.');
subplot(1,2,2);
surf(zi,thetai,r_avg)
Bruno
3 Kommentare
Bruno Luong
am 18 Feb. 2011
The reason is your matlab is old and does not support ~ operator, replace with:
[trash,trash,trash,loc] = histcn(tz, thetai, zi);
Weitere Antworten (3)
John D'Errico
am 16 Feb. 2011
No, this will not explicitly average your data points in each bin. It does better than that.
Thuan Le
am 17 Feb. 2011
4 Kommentare
John D'Errico
am 18 Feb. 2011
You CAN control the amount of smoothing using gridfit. All you have shown is that you did not read the help.
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots 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!