hold off ;
clear all ;
clf ;


% %%%%%%%%%%%%% ex1
% t=[0,2,4,6,8,10,12];
% f=[3,4,5,5.5,6.5,7,8];
% plot(t,f,'k*')

% mnt=min(t)-1;
% mxt=max(t)+1;
% axis([mnt,mxt,min(f)-1,max(f)+1]);

% p=polyfit(t,f,1)
% hold on
% val=polyval(p,[mnt,mxt]);
% plot([mnt,mxt],val,'r')
% printf("t=20 --> %f cm\n",polyval(p,20));
% printf("t=%f --> empty\n",-p(2)/p(1));
% printf("t=%f --> full\n",(50-p(2))/p(1));


% %%%%%%%%%%% ex2
% t=[2.1 2.2 2.3 2.3 2.5 2.6 2.8 2.9];
% f=[2.5 2 2.5 2.7 3 4 5.4 7];
% plot(t,f,'k*')

% mnt=min(t)-1;
% mxt=max(t)+1;
% axis([mnt,mxt,min(f)-1,max(f)+1]);

% p=polyfit(t,f,2);
% hold on
% xx=linspace(mnt,mxt,30);
% plot(xx,polyval(p,xx),'r')
% printf("t=4 --> %f\n",polyval(p,4));

% %%%%%%%%%%% ex3
% t=[0 0.5 1 1.5 2 2.5]';
% f=[1 -2 -2.5 -0.5 1.25 -1.5]';
% plot(t,f,'k*')

% mnt=min(t)-1;
% mxt=max(t)+1;
% axis([mnt,mxt,min(f)-1,max(f)+1]);

% A=[ones(size(t)),cos(pi*t),sin(pi*t)];
% format rat
% AtA=A'*A;
% Atf=A'*f;
% x=AtA\Atf;
% F=@(t) x(1)+x(2)*cos(pi*t)+x(3)*sin(pi*t);

% hold on
% xx=linspace(mnt,mxt);
% plot(xx,F(xx),'r')
