close all
clear
clc

format long

%filename = 'torque45.csv';
filename = '233_289_latao.csv';

namostras=36533;

vel2 = csvread(filename,0,0,[0,0,namostras,0]); %vel2
tor2 = csvread(filename,0,1,[0,1,namostras,1]); %torque2
sen2 = csvread(filename,0,2,[0,2,namostras,2]); %sensor2

max(tor2)

ctor2 = zeros(size(vel2));

for n=1:size(vel2)
    if (tor2(n) > 1023)
        ctor2(n) = tor2(n)-1023;
        tor2(n) = 0;
    end
    if (ctor2(n)>1024)
        ctor2(n) = ctor2(n)-1024;
    end
end
x = 1:size(vel2);

plot(x,sen2*10,x,vel2,'.',x,ctor2)
legend('Sensor x 10','Commanded torque','Torque reading')
print -deps epsFig
%ylim([0 1050])



