How to generate the hsv cone graph using Matlab?

7 ビュー (過去 30 日間)
Salad Box
Salad Box 2023 年 1 月 10 日
回答済み: Kevin Holly 2023 年 1 月 13 日
Hi
I saw the hsv cone graph on Mathworks webpage
I am wondering how to generate this graph using Matlab.
Any advices would be great. Doesn't have to be the full code.

回答 (1 件)

Kevin Holly
Kevin Holly 2023 年 1 月 13 日
Here is a starting point. I made some modifications from this code:
H = repmat(linspace(0, 1, 100), 100, 1); % 100-by-100 hues
S = repmat([linspace(0, 1, 50) ... % 100-by-100 saturations
linspace(1, 0, 50)].', 1, 100); %'
V = repmat([ones(1, 50) ... % 100-by-100 values
linspace(1, 0, 50)].', 1, 100); %'
hsvImage = cat(3, H, S, V); % Create an HSV image
C = hsv2rgb(hsvImage); % Convert it to an RGB image
% Next, create the conical surface coordinates:
theta = linspace(0, 2*pi, 20); % Angular points
X = [zeros(1, 20); ... % X coordinates
cos(theta); ...
zeros(1, 20)];
Y = [zeros(1, 20); ... % Y coordinates
sin(theta); ...
zeros(1, 20)];
Z = [2.*ones(2, 20); ... % Z coordinates
zeros(1, 20)];
% Finally, plot the texture-mapped surface:
figure
surf(X, Y, Z, C, 'FaceColor', 'texturemap');
axis equal
figure
surf(X(:,1:16), Y(:,1:16), Z(:,1:16), C(1:80,1:80,:), 'FaceColor', 'texturemap');
axis equal
view(30,32) % Adjust camera angle
hold on
patch(X(:,16), Y(:,16), Z(:,16),C(80,80,:)) % add interior purple face
patch(X(:,1), Y(:,1), Z(:,1),[1 0 0]) % add interior red face

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by