to add matlab gradient code