MATLAB: Converting 3D data to 2D 3d to 2d I have a 50×4 matrix with the columns being x, y, z, and a value. I want to average each x,y point through the z to convert my 3D data to a 2D. Best Answer So, you want to ignore the z, and average the values for each specific combination of (x,y)?xyzv = [1 1 1 10 ; 1 1 2 20 ; 1 2 3 30 ; 1 2 5 40 ; 2 2 4 10] % test data[xy,~,j] = unique(xyzv(:,[1 2]),'rows') % unique combinations of (x,y)xyv = [xy accumarray(j,xyzv(:,4),[size(xy,1),1],@mean)] % ignore z, average v Related SolutionsMATLAB: Draw 3D object.write code in 2016a version. Help me,thanks! x = linspace(0,3) ;y = linspace(0,3) ;[X,Y] = meshgrid(x,y) ;Z = 1-X.^2 ;surf(X,Y,Z)shading interp MATLAB: Average data along z [uxy, ~, uidx] = unique([x(:), y(:)], 'rows');avgv = accumarray(uidx, v(:), [], @mean);output = [uxy, avgv]; Related Question3D plot helpHow to manipulate dense 4D data
Best Answer