write matfile tested successfully