필터 지우기
필터 지우기

How to draw a variable width line?

조회 수: 13 (최근 30일)
mark palmer
mark palmer 2022년 12월 23일
답변: KSSV 2022년 12월 23일
I'm trying to draw a line that has a variable width over time. In the below, i make it go from 1 to 20 and back to 1 over 200 steps. Is this even possible? If so, what am I doing wrong?
X = linspace(1,300,3000);
Y = linspace(1,300,3000);
Y = sin(Y);
% plot(X,Y,'LineWidth', 2) % PLOTS SINE WAVE WITH LINEWIDTH OF 2
qnum = 100;
qsp = 2;
qz = round([linspace(1,qsp,qnum) linspace(qsp,1,qnum)]);
while size(qz) < 3000
qz = [qz qz];
end
for qq = 1:3000
plot(X(qq),Y(qq),'LineWidth',qz(qq))
end

채택된 답변

KSSV
KSSV 2022년 12월 23일
qnum = 300 ;
X = linspace(0,2*pi,qnum);
Y = sin(X);
qsp = 10;
qz = round(linspace(1,qsp,qnum-1));
figure
hold on
for qq = 1:qnum-1
plot(X(qq:qq+1),Y(qq:qq+1),'LineWidth',qz(qq),'color','k')
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by