How to get the matrix with the z values in cartesian coordinates from surface plot drawn in polar coordinates

1 回表示 (過去 30 日間)
I have a surface initialized in cartesian coordinates and later converted to polar coordinates.
N = 100; % number of small sectors in one segmen
row = 10; % number of segments
M = N*row;
x = 0:(1-0)/(N-1):1; % segment matrix cartesian
xx = repmat(x,M,row);
radius = 0:(2*pi-0)/(M-1):2*pi;
radius = repmat(radius,M,1);
radius = transpose (radius);
alfa = 0:1/(M-1):1;
alfa = repmat(alfa,M,1);
[X,Y,value] = pol2cart(radius,alfa,xx);
figure
h = mesh(X,Y,value);
colormap gray;
view(2);
I plot it in polar coordinates.
Now I need to get the data points from this surface (z-values only) arranged as square matrix (the same size as plot area) exactly as they look in the plot. How can I get them?
Thanks in advance.
  2 件のコメント
Matt J
Matt J 2018 年 4 月 23 日
Don't you already have them? Isn't that what "value" contains?
Mariia
Mariia 2018 年 4 月 23 日

not exactly, for some reason "value" is identical to "xx" and contains the initial xx values

Here is what will happen if I plot value

figure
g =  surf(value, 'EdgeColor','none');
 colormap gray;
view(2);

I feel like I am missing something, because for cartesian coordinates X and Y values should be both positive and negative, and I have only positive...

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

採用された回答

Mariia
Mariia 2018 年 4 月 24 日
Okay, I made it work
N = 5; % N number of radiuses
M = 1000; % resolution in pixels
[X,Y] = meshgrid(0^2^2:2*N/(M-1):2*N);
[radius,alfa] = cart2pol(X,Y);
circle = sqrt((X-N).^2+(Y-N).^2);
circlef = fix(circle);
axicon = circle - circlef;
figure
h = mesh(X,Y,axicon);
colormap gray;
view(2);
axicon array gives what I need

その他の回答 (0 件)

カテゴリ

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