close all
clear
clc

filename = 'const_elast.csv';

[status, result] = system( ['wc -l ', filename] );
Index = strfind(result, ' ');
Namostras = sscanf(result(1:Index), '%i', 1);
namostras = Namostras-1;
format long


sen2 = csvread(filename,0,0,[0,0,namostras,0]); % 
pos2 = csvread(filename,0,1,[0,1,namostras,1]); % 

x=1:(size(pos2));

b=86740; %(1:b)

subplot(4,1,1)
plot(x(30000:b),sen2(30000:b))
ylim([0 15])
subplot(4,1,2)
plot(x(30000:b),pos2(30000:b))


   p = polyfit(pos2(30000:b),sen2(30000:b),2)
   pp = polyfit(pos2(30000:b),sen2(30000:b),1)
   
   
%    f = polyval(sen2,x);
%    [r2,rmse] = rsquare(y,f);
%    figure; plot(x,y,'b-');
%    hold on; plot(x,f,'r-');
%    title(strcat(['R2 = ' num2str(r2) '; RMSE = ' num2str(rmse)]))
   
subplot(4,1,3)
plot(x(1:b),1e3*( 0.000000151479202.*x(1:b).^2 -0.001153599362733.*x(1:b)  ))
   
subplot(4,1,4)
plot(x(1:b), 1.0e+02 *(0.000270121133506.*x(1:b) ))
    
   