close all; clear; clc

figure
line = animatedline("Color", "red");
line2 = animatedline("Color", "blue");
xlim([0, 10])
ylim([-1, 1])
xlabel("x")
ylabel("f(x)")
legend("sin(x)", "cos(x)")

dt = 0.0001;
t = 0:dt:10;

omega = 2;

for i = 1:length(t)
    addpoints(line, t(i), sin(omega * t(i)))
    addpoints(line2, t(i), cos(omega * t(i)))
    drawnow limitrate
end