How to animate two functions at the same time?

Hello,
I don't know how to animate these 2 functions at the same time, maybe using comet, or some type of loop?
If you have any ideas please help.
Here is my code:
clear all;
clc;
close all;
x1=0:0.1:exp(1)-0.01;
x2=exp(1)+0.01:0.1:10;
y1=(log(x1)/log(exp(1))-2)./(log(x1)/log(exp(1))-1); %first function
y2=(log(x2)/log(exp(1))-2)./(log(x2)/log(exp(1))-1); %second function
f=plot(x1,y1);
hold on;
g=plot(x2,y2);
hold off;
xlim([-1 10]); ylim([-30 30]);
grid on;

 采纳的回答

m = 100 ;
x1=linspace(0,exp(1)-0.01,m);
x2=linspace(exp(1)+0.01,10,m);
y1=(log(x1)/log(exp(1))-2)./(log(x1)/log(exp(1))-1); %first function
y2=(log(x2)/log(exp(1))-2)./(log(x2)/log(exp(1))-1); %second function
X = [x1' x2'] ;
Y = [y1' y2'] ;
for i = 1:m
plot(X(1:i,:),Y(1:i,:)) ;
drawnow
end

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Animation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by