Réponse acceptée

sabidha
sabidha le 17 Mai 2023

0 votes

随手写的
t=0:0.05:2*pi;
x=sin(t)+0.1*rand(size(t));
theta=linspace(0,2*pi,length(t));
R=2;
xmax=max(x);
xmin=min(x);
c=linspace(xmin,xmax,6);
r={'5e' 'be' 'ff' 'ff' 'ff' 'f9'};
g={'6c' '6d' '76' '96' 'c5' 'f8'};
b={'c2' 'bf' 'a3' '7f' '65' '71'};
r=hex2dec(r)/255;
g=hex2dec(g)/255;
b=hex2dec(b)/255;
subplot(2,1,1)
plot(R*cos(theta),R*sin(theta),'black')
axis equal
hold on
x0=nan;
y0=nan;
for i=1:length(t)
    x1=R*cos(theta(i));
    y1=R*sin(theta(i));
    x2=(R+x(i))*cos(theta(i));
    y2=(R+x(i))*sin(theta(i));
    plot([x1,x2,x0],[y1,y2,y0],'Color',[interp1(c,r,x(i)),interp1(c,g,x(i)),interp1(c,b,x(i))])
    x0=x2;
    y0=y2;
end
subplot(2,1,2)
plot(t,x)

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!