%%
clear
[ DN, DT, RAW ] = xlsread('Dados_carros_agrupados.xls');
%%
qual = 12;
iok = find( isfinite(DN(:,1+2*(qual-1))) );
t = DN(iok,1+2*(qual-1));
v = DN(iok,2+2*(qual-1))/3.6;
nome_carro = DT{1,2+2*(qual-1)};

vlim = 100/3.6;
ifit = find( v<=vlim );
% A = polyfit( sqrt(t(ifit)), v(ifit), 1 );
A = polyfit( t(ifit), v(ifit).^2, 1 );

figure
subplot(3,1,1:2)
plot( t, (v*3.6).^2, '*' )
hold on
plot( t, (3.6)^2*polyval( A, t ), '-r' )
plot( t(ifit), (v(ifit)*3.6).^2, 'ok' )
title( sprintf( '%s, aM = %.2f   vc = %.2f km/h', ...
    nome_carro, (1/sqrt(-A(2)))*(A(1)/2), sqrt(-A(2))*3.6 ), 'fontsize', 18 )
subplot(3,1,3)
plot( t, ((3.6*v).^2-(3.6)^2*polyval(A,t)), '*' )
