# Replicate a colormap in MATLAB

5 Ansichten (letzte 30 Tage)
Richard Wood am 7 Mär. 2023
Bearbeitet: DGM am 7 Mär. 2023
Hello everyone
I have been asked to replicate this type of color coding based on the value of angles in spherical coordinates (see file attached) in MATLAB. How could I do it? Any advice?
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

DGM am 7 Mär. 2023
Bearbeitet: DGM am 7 Mär. 2023
I am not even remotely familiar with POV-ray, so I have no expecations or any way to verify this. That said, this is what it looks like as I wrote it:
% generate angle fields
n = 100; % page geometry
theta0 = linspace(0,360,n);
phi0 = linspace(0,180,n);
[theta phi] = meshgrid(theta0,phi0);
% generate color field
outpict = colorball2(theta,phi);
image(theta0,phi0,outpict)
That doesn't look generally useful. Given the odd reference colors and the uneven variation, I have no idea what it's supposed to be used for. Something tells me that part of this may not be intended to be done in sRGB.
If you think my interpretation is wrong, this example uses a rather literal copy of what's given.
% generate angle vectors
n = 100; % page geometry
theta = linspace(0,360,n);
phi = linspace(0,180,n);
% generate color field pointwise
outpict = zeros(n,n,3);
for r = 1:n
for c = 1:n
thisrgb = colorball(theta(c),phi(r));
outpict(r,c,:) = thisrgb;
end
end
image(theta,phi,outpict)
Attached are both function files and their supporting files.
If that's not what's expected and you have an example of what the results should look like for a full sweep, then post them.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Image Analyst am 7 Mär. 2023
Not sure what that does but if you're interested in a color wheel, see my attached demo.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Blue finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by