AC motor model and MATLAB implementation