clear all;close all;clc xx=-1:0.01:3; f=inline('x.^2'); % definition de la fonction, ici la fonction carre... a=1; % tangente au point d abscisse a figure(1);clf; % Bornes des axes minx=-1;maxx=4; miny=-1;maxy=8; cpt=0; H=[1.5:-0.05:0.05,0.05:0.01:0.01,0.001,0.0001]; for h=H figure(1);clf; cpt=cpt+1; alpha=(f(a+h)-f(a))/h; b=f(a)-a*alpha; zz=alpha*xx+b; pp=plot(xx,f(xx),'-r',xx,zz,'-b'); axis([minx maxx miny maxy]); hold on; % Les traits de construction plot(a,minx:0.1:f(a),'--k') plot(0:0.05:a,f(a),'--k') plot(a+h,minx:0.1:f(a+h),'--k') plot(0:0.05:a+h,f(a+h),'--k') % Les axes du repere arrowline([minx maxx-0.5],[0 0],'arrowsize', 100,'color','k'); arrowline([0 0],[miny maxy-2],'arrowsize', 100,'color','k'); % Texte sur la figure text(a-0.2,f(a)+0.2,'A','fontsize',20); text(a+h-0.2,f(a+h)+0.2,'M','fontsize',20); mytexstr = ['$\frac{f(a+h) \mbox{-} f(a)}{h}=$',num2str(alpha)]; tt = text('string',mytexstr,... 'interpreter','latex',... 'fontsize',30,... 'units','norm',... 'pos',[0 0.9]); arrowline([a a+h],[miny+0.2 miny+0.2],'arrowsize', 100,'color','k'); texth=['h=',num2str(h)]; text('string',texth,'fontsize',10,'pos',[1.1 -0.6]); textfah=['$f(a+h)=$',num2str(f(a+h))]; text('string',textfah,... 'interpreter','latex',... 'fontsize',12,... 'pos',[-1 f(a+h)]); textfah=['$f(a)=$',num2str(f(a))]; text('string',textfah,... 'interpreter','latex',... 'fontsize',12,... 'pos',[-0.7 f(a)]); MM(cpt)=getframe; pause(0.001) end %% Enregistrer le film au format avi: % movie2avi(MM,filename.avi); % %% Conversion en gif anime (utilisant la commande unix 'convert'): % convert filename.avi filename.gif