Rotating a line plot to obtain a 360-degree color map

23 views (last 30 days)
Keyur Savla on 12 Jul 2024 at 19:27
Answered: Star Strider on 12 Jul 2024 at 20:47
I would like to rotate the line plot on the left about its central point to create a 360 degree color map, that looks somewhat like to the image on the right. Any suggestion on how to rotate and extrapolate the data?

Star Strider on 12 Jul 2024 at 20:47
Itt would help to have the data.
It also appears that the line is not the same everywhere (it may be part of a matrix), although only one line (most likely row) is shown.
One ap;proach is tot create a matrix from it as a function of an angle, and then use the pol2cart function to transform it into Cartesian coordinates —
Nr = 250;
th = linspace(0, 2*pi, Nr);
Nc = 50;
rv = linspace(0, 3.5*pi, Nc);
r = cos(rv) + 1;
figure
plot(rv, r)
[T,R] = ndgrid(th, rv);
A = repmat(r, Nr, 1);
figure
surf(T, R, A, 'EdgeColor','none')
colormap(turbo)
colorbar
[X,Y,Z] = pol2cart(T, R, A);
figure
surf(X, Y, Z, 'EdgeColor','interp')
colormap(turbo)
colorbar
figure
surf(X, Y, Z, 'EdgeColor','interp')
colormap(turbo)
colorbar
axis('equal')
view(0,90)
Depending on how you want it to look, another option is tto use contourf
figure
contourf(X, Y, Z, 'LineColor','none')
colormap(turbo)
colorbar
axis('equal')
This is my best guess.