How to create moving text

조회 수: 6 (최근 30일)
Rajawarman Thiruselvam
Rajawarman Thiruselvam 2021년 7월 6일
편집: Jonas 2021년 7월 7일
Is it possible to create a moving text along with a line??

채택된 답변

Jonas
Jonas 2021년 7월 6일
you can move the text every now and then by changing the coordinates. e.g.
data=randi(42,100,1);
m=mean(data);
plot(data);
yline(m);
tx=text(1,1.1*m,'some text','Color','r');
for xCor=2:80
tx.Position=tx.Position+[1 0 0];
pause(0.1)
end
  댓글 수: 5
Rajawarman Thiruselvam
Rajawarman Thiruselvam 2021년 7월 7일
and this ??
tx.Position=[x(k),1.1*y(k)]
Jonas
Jonas 2021년 7월 7일
편집: Jonas 2021년 7월 7일
tx=text(x(1),1.1*y(1),'lead');
creates the text label 'lead' near x(1) and y(1). i used 1.1*y(1) to be sure that the label is not exactly on the point of the curve i want to label but a bit above
similarly i use a slightly bigger y when i move the label according to the further points of the curve

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by