Complete test_sae base on matlab code.