フィルターのクリア

How do i put a center of surface in [0 0] coordinates

11 ビュー (過去 30 日間)
Karel Schindler
Karel Schindler 2023 年 1 月 13 日
回答済み: Sarthak 2023 年 3 月 7 日
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
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;
Karel Schindler
Karel Schindler 2023 年 1 月 13 日
I already figured it out thank you. It was:
val1=-centerX:centerX-1;
val2 = 20-centerY:centerY-1-20;
[xmesh, ymesh] = meshgrid(val1,val2);
sl=mesh(xmesh, ymesh,wl)

サインインしてコメントする。

回答 (1 件)

Sarthak
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:

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by