Borrar filtros
Borrar filtros

3-D Polar Plot from mat Data

9 visualizaciones (últimos 30 días)
Naeem
Naeem el 18 de Dic. de 2023
Comentada: William Rose el 2 de En. de 2024
I am facing a problem in plotting of a data in Polar coordinate. The attached .Mat file “Polar_Data” is the data extracted from a maxwell solver software (Lumerical FDTD) which gives us the same polar plot in FDTD software as hereby shown in the following attached figure. Now I want to plot the same type of image from the extracted data. I tried different commands (polar3, polarplot3d, etc) for plotting of such image but still I didn’t produce the same image in Matlab. It would be so nice of you if use my attached data and help me in writing script to obtain the same image. Thanks in advance.
  1 comentario
Dyuman Joshi
Dyuman Joshi el 18 de Dic. de 2023
How do you expect to plot data depending on two independent variables on a 2D plot?
Or does the software provide a 2D view of the surface plotted?

Iniciar sesión para comentar.

Respuesta aceptada

William Rose
William Rose el 19 de Dic. de 2023
Editada: William Rose el 19 de Dic. de 2023
[Edit: added references to the File Exchange programs you referenced.]
I am surprised that you were not satisfied with polar3d or polarplot3d, from the Matlab File Exchange. Those packages look very nice to me. What exactly did you not like about polarplot3d?
farfield is 500x500, r is 1x500, and theta is 1x500. Therefore I cannot tell if the rows or the columns of farfield correspond to R and theta. When I plot the data, it appears that the rows of farfield correspond to different r values, and the columns correspond to different theta values. I recommend that when you have data on a surface, the surface should have different numbers of rows and columns, if possible. If they have the same numbers of rows and columns, you can plot the data incorrectly, or do incorrect calculations, without realizing that you have made an error. (Ask me how I know...) Therefore I eliminated the last row of farfield and the last element of r, and saved the resulting r, theta, and farfield in file Polar_Data1.mat, attached. In my file, farfield is 499x500, r has length 499, theta has length 500.
I do not believe that the data file you provided actually yielded the figure you posted. I say this for the following reasons:
A. The r values in the figure you posted vary from 0 to more than 50 (see radial axis axis labels on your figure), but the r values in the file you sent vary from 0 to 10.
B. The figure you posted has peaks at theta=[0,pi], and at r~=[42,42], but the farfield array has peaks at theta=[pi/3, 5*pi/3], and r=[5.0,5.0].
Here is code that generates two surface plots. The first plot uses r and theta as Cartesian cooridnates. This is not the plot you want. The second plot uses r and theta as polar coordinates. This is more like what you want.
load Polar_Data1
figure;
surf(theta,r,farfield,'EdgeColor','none');
xlabel('$$\Theta$$','Interpreter','latex'); ylabel('R')
view(0,90); colormap jet; colorbar
[Theta,R]=meshgrid(theta,r);
X=R.*cos(Theta); Y=R.*sin(Theta);
figure;
surf(X,Y,farfield,'EdgeColor','none');
axis equal; view(0,90); colormap jet; colorbar
The spacing of the radial gridlines on the figure you posted suggests that the figure is an orthographic projection of a sphere, where the view is from above the north pole, the azimuth corresponds to longitude, and the un-evenly spaced radial values are the co-latitudes (i.e 0 at the pole and +90 at the equator). But the r-values in your file do not vary from 0 to 90. Please clarify.
Good luck.
  5 comentarios
Naeem
Naeem el 2 de En. de 2024
Finally you did it and you have successfully implemented. It’s exactly the same what I need it. Thanks for the support and guidance.
William Rose
William Rose el 2 de En. de 2024
@Naeem, you're welcome. Good luck with your work.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Marine and Underwater Vehicles en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by