transform a matrix with polar coordinates into a matrix with cartesian coordinates

hi, I have two sets of data, each of which I need to process. After the transformation a matrix must come out at the end of each.
i found two approaches. once you can plot them and put a meshgrid on them, and then convert the newly found points. Or you can somehow use pol2cart.
This is recorded data in a helix structure. Always the angle and the radius.
the original matrix data looks like this with imagesc https://imgur.com/a/YT7wuec
and I know something like that is supposed to come out: https://imgur.com/a/toYaqDC
My dataset looks like this: DataSet (512x1000)
in the lines is the radius, and in the columns the angle.
now I want to convert my single elements in the matrix PolMat into cartesian coordinates. And save this matrix as CartMat.
thanks for the help
MATLAB Version: 9.8.0.1380330 (R2020a) Update 2

回答 (1 件)

KSSV
KSSV 2020 年 7 月 7 日
編集済み: KSSV 2020 年 7 月 7 日

1 投票

9 件のコメント

I have done that, but I can't get the data into a new matrix. With data from the internet and the instructions I can also plot a cartesian picture. But not to store my data in a matrix.
angles = linspace(0, 2*pi, size(PolMat,2));
radii = linspace(1, 100, size(PolMat,1));
[A, R] = meshgrid(angles, radii);
[x,x,z] = pol2cart(A, R, PolMat);
surf(x,y,z)
view(0,90);
shading('interp')
I can only output them graphically in 3D. And then change the view to 2D.
[x,x,z] = pol2cart(A, R, PolMat);
pol2cart accepts only two inputs.....are you looking for sph2cart ?
Max M
Max M 2020 年 7 月 7 日
編集済み: Max M 2020 年 7 月 7 日
The documentation says: [x,y,z] = pol2cart(theta,rho,z) transforms corresponding elements of the cylindrical coordinate arrays theta, rho, and z to three-dimensional Cartesian, or xyz, coordinates.
and in the example:
[x,y,z] = pol2cart(theta,rho,z)
that's exactly what I want to do (I think), and with surf you also get a decent picture when you look at it from above. But I would like to save it in a matrix.
i have a spiral (or hold a hose if the spiral is very tight) and no sphere or sphere. So I think sph2cart isn't the right for my purpose.
KSSV
KSSV 2020 年 7 月 7 日
I have just checked your DataSet....you got a matrix of size 512*1000...you want to wrap this matrix into a helix ?
Max M
Max M 2020 年 7 月 7 日
編集済み: Max M 2020 年 7 月 7 日
yes almost, the data that is available is already a helix, but stored in the individual cells as polar coordinates. I want the same matrix as the Cartesian coordinates.
somehow this works with cart2pol and the (x,y,z) but I can't get it stored in a matrix.
I need a matrix with which I can read the single "heights" with imagesc.
with contur i have now also made it out of my 3 vectors (x,y,z) but i need to get them into a matrix.
contour(x,y,z,[200 200]) %at height of 200
thank you very much for your efforts
[x,y,z] = pol2cart(A, R, PolMat);
z = double(z) ;
In the above x, y, z are matrices already.
Max M
Max M 2020 年 7 月 7 日
編集済み: Max M 2020 年 7 月 7 日
Now when I run imagesc(z) I get back my original polar matrix image. https://imgur.com/a/YT7wuec
but I would like to have one that looks like my surf(x,y,z) https://imgur.com/a/toYaqDC
  • EDIT:
  • I think i can get the image also with
contour(Xc,Yc,Zc,[1:512 1:512],'-')
  • but my computer can't make with amount of calculation
the records look exactly the same. So PolMat=z only with double instead of uint16
is it not possible to convert the polar matrix polmat into a cartesian matrix and then use imagesc(cartmat) to get the image like in surf? https://imgur.com/a/toYaqDC
When you try
surf(z)
pcolor(z)
also you will get back your original value. By specifying x,y, you can plot it as a circle or as what you wanted.
Max M
Max M 2020 年 7 月 7 日
yes, but surf(z) is again there picture of my polar data :)
I want the polar data from (z) ((in z the polar data are stored as a matrix))transforming into Cartesian data. And then store this data in a new matrix.
The only thing I'm trying to do is store another matrix that doesn't contain polar data but Cartesian data.

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

カテゴリ

ヘルプ センター および File ExchangePolar Plots についてさらに検索

製品

質問済み:

2020 年 7 月 7 日

コメント済み:

2020 年 7 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by