Add function to export trajectory