some MATLAB code to analyze hysteresis