How can i add text in animated line

9 ビュー (過去 30 日間)
Rajawarman Thiruselvam
Rajawarman Thiruselvam 2021 年 7 月 7 日
コメント済み: Star Strider 2021 年 7 月 8 日
In this program, I have done with animated line plot, here how can i add text only when the line reaches to end or in some middle point. how can i do this?
clear all
close all
clc
figure
h = animatedline('linewidth',2);
axis([1 7 1 7])
axis ij
grid on
x=1:4;
n = 100;
xx=linspace(x(1),x(end),n);
y = [1 1 2 1];
yy = interp1(x,y,xx);
for ci=1:n
addpoints(h,xx(ci),yy(ci));
pause(0.03);
drawnow
end

採用された回答

Star Strider
Star Strider 2021 年 7 月 7 日
編集済み: Star Strider 2021 年 7 月 7 日
Try this —
figure
h = animatedline('linewidth',2);
axis([1 7 1 7])
axis ij
grid on
x=1:4;
n = 100;
xx=linspace(x(1),x(end),n);
y = [1 1 2 1];
yy = interp1(x,y,xx);
for ci=1:n
addpoints(h,xx(ci),yy(ci));
pause(0.03);
drawnow
if yy(ci) == max(y)
text(xx(ci), yy(ci), '$\uparrow Maximum$', 'Horiz','left', 'Vert','top', 'Interpreter','latex')
end
if ci == n
text(xx(ci), yy(ci), '$\leftarrow End$', 'Horiz','left', 'Vert','middle', 'Interpreter','latex')
end
end
EDIT — (7 Jul 2021 at 16:40)
Corrected typographical error.
.
  6 件のコメント
Rajawarman Thiruselvam
Rajawarman Thiruselvam 2021 年 7 月 8 日
how can i create movie for this program?? how can i do this?
Star Strider
Star Strider 2021 年 7 月 8 日
The movie function documentation describes one approach. (That seems to be the only option.)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by