He was arrested on June 29, after he was linked to the killing, when he spoke to police and soldiers in Horseguards Parade, the court heard.
The 27-year-old Afghan, who lived in Sheffield before arriving in London, pleaded guilty to manslaughter on the grounds of diminished responsibility. He was ordered to be detained in a secure hospital without limit of time.
Former chef Mr Morrison, who was born in Dunblane, had been sleeping on a bench at Marble Arch since being made homeless a few months before.
Judge Christopher Moss criticised doctors who examined Barani before the killing.
He said: "I have no doubt from what I have read and heard that (the death) was entirely preventable."