The Yamato Cannon charges up for 3 seconds, then releases an intense blast of concentrated energy at the target, dealing 240 points of damage. Although the casting range is 10, once the spell has been initiated, the target will be affected within a range of 20. Yamato Cannon will not cancel itself if a target enters a transport or becomes cloaked/burrowed. Instead, the Yamato Cannon will miss, and the ability will go on cooldown.
Overall, Yamato Cannon is used to deal high damage in a burst to targets of high-importance for your opponent's army. This can include Thors, other Battlecruisers, static defenses, Carriers, and so on.
It is also a very good spell for speeding up the destruction of tech buildings if your opponent is not at his base when you attack.
With the Battlecruiser's weapon range of only 6 and its very low mobility, the Yamato Cannon is used defensively to quickly dispose of natural enemies such as Vikings, Corruptors or Void Rays.
Two Yamato Cannons will kill a Carrier.
Void Rays make excellent targets as they are very dangerous against Battlecruisers.
Battlecruiser vs Battlecruiser battles can sometimes occur, and these battles are usually decided by the Yamato Cannon ability. The spell is also extremely useful against Thors, as well as against Vikings attempting to kite the Battlecruiser.
Zerg does not have any units which are very good targets for the Yamato Cannon ability, but it can help to quickly destroy a large force of Brood Lords, and can also be used to defend against Ultralisks attacking a base.
Yamato Cannon use also helps Battlecruisers quickly kill Corruptors.