How to put a color in a this graph? (code)

The code is:
R=3;
R2=2;
for i=1:2
for j=1:6
t=linspace((i-1)*60*pi/180,i*60*pi/180);
t2=linspace(i*60*pi/180,(i-1)*60*pi/180);
x=(R-(j-1))*cos(t):
y=(R-(j-1))*sin(t);
x2=(R2-(j-1))*cos(t2);
y2=(R2-(j-1))*sin(t2);
X=[x2.x.x2(1)];
Y=[y2,y,y2(1)];
figure
patch(X,Y,'r')
axis equal
end
end
I tried to use "imagesc(X,Y,c)" where c is a vector with some values.
I want to know how to colorate the graph where the color has to be related to each value of "c".

2 Commenti

provide c datas
C=[500 600 750.6 800 400.7 350 500.4 487.3 125.6 258.6 158.3 147.6]

Accedi per commentare.

Risposte (1)

C=[500 600 750.6 800 400.7 350 500.4 487.3 125.6 258.6 158.3 147.6]
R=3;
R2=2;
for i=1:2
for j=1:6
t=linspace((i-1)*60*pi/180,i*60*pi/180);
t2=linspace(i*60*pi/180,(i-1)*60*pi/180);
x=(R-(j-1))*cos(t);
y=(R-(j-1))*sin(t);
x2=(R2-(j-1))*cos(t2);
y2=(R2-(j-1))*sin(t2);
X=[x2,x,x2(1)];
Y=[y2,y,y2(1)];
figure
patch(X,Y,'r')
axis equal
end
end

Categorie

Scopri di più su Graph and Network Algorithms in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by