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

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

Dx_esperado = (2/3)*A(1)*t(end-1:end).^(3/2);
disp( sprintf( '%.0f ', Dx_esperado ) )
figure
subplot(3,1,1:2)
plot( sqrt(t), v*3.6, '*' )
hold on
plot( sqrt(t), 3.6*polyval( A, sqrt(t) ), '-r' )
plot( sqrt(t(ifit)), v(ifit)*3.6, 'ok' )
title( nome_carro )
subplot(3,1,3)
plot( sqrt(t), 3.6*(v-polyval(A,sqrt(t))), '*' )
