Andy Murray suffered a third set ankle injury and a dramatic third round defeat 7-5, 5-7, 6-7 (5) to Tomas Machac in the Miami Open.