How can I plot intensity as colour against a polar plot?

Hi,
I have a set of radial and angular values that cover a hemisphere volume. I've converted these values to cartesian coordinates and plotted it here so you can visualise (in reality I have many more points than this but it is then too dense to see):
For each of these (x, y) or (r, theta) points, I have a corresponding intensity function, F. I have tried plotting this along with the (x,y) points above with imagesc but it goes completely wrong. I have looked at colormap and pcolor etc also but I never get a plot with a hemisphere as above, it usually comes out as variations of a big blue square. Essentially what I am expecting to see is a rainbow, as my intesity functions varies radially only.
I don't mind whether I do a polar plot or convert to cartesian as above, but can anyone talk me through the steps of how to plot F as a colour?
I essentially have a radius vector R, a smaller vector A that runs from 0 to pi, and a vector F the same length as R. I have been able to convert to cartesian within a For loop such that I get x and y of equal vector sizes and also a vector of the same size F, where F basically repeats itself wherever R is unchanged.
Thanks

2 commentaires

In my eyes this is not a duplicate, it is a different question about the same problem. The first question hadn't helped me to solve my problem as I didn't get any responses. The style of that question was basically me explaining my code, stating that it didn't work and asking for solutions to my particular code. I thought I might not have received any responses because it was poorly phrased. So I created this question in a different style, simply stating what I wanted to do in a broader sense of plotting intensity as colour and asking for suggestions of how to achieve it.
I would have deleted the first but then I saw you had replied and now I am trying to get to the bottom of how to do this using your help, which I'm sure is expert advice but is just not working for me yet.

Connectez-vous pour commenter.

Réponses (1)

Hi Orla,
As per my understanding the issue you are encountering with plotting intensity as colour on a polar plot can be effectively addressed by converting your polar coordinates to Cartesian coordinates and then using MATLAB's plotting functions designed for Cartesian plots. Here's a brief example:
First we need to form a mesh over radius and angle by creating a grid using your radial(R) and angular values(A):
[Rgrid, Agrid] = meshgrid(R, A);
Next we need to transform polar coordinates to cartesian coordinates:
X = Rgrid .* cos(Agrid);
Y = Rgrid .* sin(Agrid);
Next we need to build a 2D array for the intensity, so if your intensity function (F) depends only on (R), replicate it for each angle:
Fgrid = myF(Rgrid); % Example function
At last, we need to use the ‘pcolor’ function to display the intensity as colour:
figure;
pcolor(X, Y, Fgrid);
shading interp;
colormap jet;
colorbar;
axis equal;
I tested the above code and successfully generated an image that visually represents the intensity as a colour gradient, forming your desired semicircle "fan" effect.
For a better understanding of the above solution, refer to the following MATLAB documentations:

Catégories

En savoir plus sur Data Distribution Plots dans Centre d'aide et File Exchange

Réponse apportée :

le 23 Fév 2025

Community Treasure Hunt

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

Start Hunting!

Translated by