There are two ways to do it with Samsung Galaxy S4. The two ways are the Wired method and the Wireless Method, which both require a bit of extra hardware to get the job done.
Lets go over the Wired Method first. For this you will need to get a Samsung MHL to HDMI Adapter.
•Before plugging in any cables you need to adjust some Settings.
•Settings > My Device Tab > Accessory > Audio Output > Put a check mark next to Surround
•Connect one end of your hdmi cable to the tv and the other end of the cable goes into the mhl adapter. The mhl adapter has a female HDMI recepticle in one end of it.
•Connect the power cable (for the mhl adapter) into the wall and then put the other end of the power cable into the mhl adapter. The mhl adapter itself needs to be powered in order to work.
•Set the TV to the proper Input and you will now see what is displayed on the phone on the TV.
Now for the Wireless Method. Keep in mind the wireless method may have lower picture quality than the wired method does. For this you will need to get a Samsung Allshare Cast Dongle.
•Connect the Dongle to the TV and select that Input.
•When the light on the Dongle blinks Red press the Reset button until it turns Blue.
•On the Phone go to Settings > Connections Tab > Screen Mirroring and turn that on.
•After a few moments the Dongle will appear on the list of devices.
•Tap the device on the list and it will start mirroring the phone on the TV.