How do i put a center of surface in [0 0] coordinates
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi,
I made a 3d surface graph from matrice. I already count a center of this surface, but how do i shift the center of the surface to (0 0) coordinates ? I want to keep z coordinate as it is. Bassicily the origin of x and y must be in the center of surface.
%% Nacteni dat
[Zmeas, dx, wl]= ReadXYZ(measurementFile ,dataFolder);
%Vypocet teziste masky
sizeX = size(Zmeas,2);
sizeY = size(Zmeas,1);
%Vypocet stredu
Zshape = ~isnan(Zmeas);
centerX = 0;
centerY = 0;
cnt = 0;
for m=1:sizeY
for n=1:sizeX
if (Zshape(m,n))
centerX = centerX + n;
centerY = centerY + m;
cnt = cnt + 1;
end
end
end
centerX = int32(centerX/cnt);
centerY = int32(centerY/cnt);
%Odecteni offsetu a naklonu [piston tip tilt power]
[Zmeas, dx, wl] = RemoveZernikes(Zmeas, Zshape, [1 1 1], centerX, centerY);
%graf
figure
sl=mesh(wl);
colormap("jet");
xlabel("x"); ylabel("y"); zlabel("z");
title("Odchylky povrchu");
zlim([-.5 .5]);
ylim([0 600]);
xlim([0 600]);
view([135 30]);
%movegui('center');
colorbar
daspect([100 100 1])
댓글 수: 2
Mathieu NOE
2023년 1월 13일
Hello
simply retrieve the center coordinates to your data X,Y coordinates (where are they in your code ?)
X = X - centerX;
Y = Y - centerY;
답변 (1개)
Sarthak
2023년 3월 7일
Hi,
To shift the center of the surface to (0,0), you need to subtract the coordinates of the center point from all the x and y coordinates of the surface points.
Refer to the code and documentation on meshgrid below-
x = ((1:sizeX)-centerX)*dx;
y = ((1:sizeY)-centerY)*dx;
[X,Y] = meshgrid(x,y);
Documentation:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!