M=pmsm_estim_mex('real_mx.cfg');

ids = [1:size(M.mean_EKFMz,1)];
kftime=[ids-ids(1)]*0.000125;

figure(1);
subplot(2,1,1);
hold off
plot(kftime,M.mean_EKFMz(ids,3)/2/pi,'-.');
hold on
plot(kftime,M.mean_EKF(ids,3)/2/pi,'r');

title('Measured and estimated \omega_{me}');
xlabel('time [s]')

subplot(2,1,2);
plot(kftime, M.mean_EKFMz(ids,5));
title('Estimated load T_L');


% ----- 

load ~/work/vs/Pohony/DATA_MERENI/DATA_MCU/data9.dat -ascii

data=data9;

subplot(2,1,1);
setime=[0:799]*0.004666; % fitted on currents
plot(setime,data([0:799]+711,6),'--k','LineWidth',3);
%plot(setime,data([0:799]+711,11),'--g','LineWidth',3);
%plot(setime,2*pi*data1([0:799]+620,6),'--k','LineWidth',3);

legend('EKF T_L estimate','EKF estimate','Sensor readings')

set(gca,'XLim',[0,kftime(end)])