pol2cart with matrices

16 vues (au cours des 30 derniers jours)
prrrrr
prrrrr le 4 Juil 2020
Commenté : Star Strider le 5 Juil 2020
i have polar coordinates in a matrix 512x500 which can be displayed as in A with imagesc.
I can now convert them into cartesian coordinates. Since it is a spiral they will actually be cylindrical coordinates.
With
angle= linspace(0, 2*pi, size(polvec,2));
rad = linspace(1, 100, size(polvec,1));
[x,y,z] = pol2cart(a,b,c);
figure
surf(x,y,z)
view(2);
I also get a 2-D plot from above (B). But how do I convert this into a real 2-D transfomation? And how do I get a matrix out of it that now stores my data in 2D coordinates?
Thanks
  2 commentaires
the cyclist
the cyclist le 4 Juil 2020
Can you upload your data in a MAT file (using the paper clip icon in the INSERT section of the toolbar here)?
prrrrr
prrrrr le 5 Juil 2020
it is a very big file and my internet connection is not s good. I have added an randi in a comment below

Connectez-vous pour commenter.

Réponses (1)

Star Strider
Star Strider le 4 Juil 2020
This appears to be the same as: using surf and pol2cart on matrix.
You can get a 2D plot of it by using:
view(0,90)
Another (probably better) option would be to use the contour function instead of surf or mesh. The arguments are the same.
  4 commentaires
prrrrr
prrrrr le 5 Juil 2020
Modifié(e) : prrrrr le 5 Juil 2020
i think i have it now already so with a random example. the other file is very large.
there i have the surface on the left and the contour on the right. I just don't know how to display the contour at a certain height. So only one slice. and of it I still try to save the matrix, each in a height. and the whole system.
thanks a lot for this great help here. i think matlab is great and i want to learn it (somehow you can do everything with it) but i am still at the beginning,
EDIT: Forgotten the Code :/ sorry
Z = randi([50 300],512,500);
angles = linspace(0, 2*pi, size(Z,2));
radii = linspace(1, 10, size(Z,1));
[A, R] = meshgrid(angles, radii);
[X, Y, Z] = pol2cart(A, R, Z);
subplot(1,2,1);
surf(X,Y,Z)
shading('interp')
grid on
title('surf')
subplot(1,2,2);
contour(X,Y,Z)
title('contour')
Star Strider
Star Strider le 5 Juil 2020
To display the contour at a specific height, specify the height:
contour(X,Y,Z, [150 150])
Here, it will show the contour at 150. (This is described in the documentation.)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by