关于matlab的绘图。

请教这幅图怎么绘制出来的呢,谢谢

 Accepted Answer

sabidha
sabidha on 17 May 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)

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Asked:

on 17 May 2023

Answered:

on 17 May 2023

Community Treasure Hunt

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

Start Hunting!