If you don't have a lot of time and want to get from A to B, then take 41 South to 99 South to Bakersfield, then take 58 East to 15 North to 40 East.
But if you want to spend a little extra time, I would HIGHLY HIGHLY recommend leaving Yosemite on 120 to 395, take 395 South to 58, 58 East to 15 North (just a few miles) to 40 East. If you have a couple days, stop and visit some of the sights.
The 120 through Yosemite high country is BREATHTAKING. Be sure to stop and take pictures of the back side of Half Dome, and have lunch at Tenaya Lake. The road is fine for RVs, a bit windy but no nose meets tail turns, and not too steep. The section from Tioga summit down to Lee Vining is 8%, just gear down and enjoy the view of Mono Lake. By the way, I have heard the deli at the gas station at the corner of 120 and 395 is highly rated.
The drive down 395 along the Eastern Sierras one of the most scenic in CA. You could easily spend an entire vacation along this stretch of road. Take a short detour North to the Mono Lake visitor center, very interesting! Then head South. Just South of Lee Vining is the June Lake loop, Mammoth Lakes ( I stayed a week here) and Devils Postpile. Lake Crowley, Bishop (don't miss Schat's Bakery).
At Big Pine, if you have time for a detour, drop the trailer and drive up the 168 to White Mountain road and the Ancient Bristlecone Pine forest, the oldest trees in the world. Just South of Independance is the Manzanar Japanese Internment camp.
Lone Pine is the gateway to Mt Whitney, tallest peak in the lower 48 (up for a vigerous day hike :))
If you don't mind another detour, at Inyokern take 14 instead of staying on 395 and stop at Red Rock Canyon state park. Just south of Red Rock Canyon you can take Red Rock / Randsberg road back to 395.
Take 395 South to 58 and go East. At Barstow, if you have time get off at W Main street. and turn left. Then turn left on N 1st street. Drive over the bridge and stop at the old Harvey House. It now houses a Route 66 museum and Western Rail Road museum. The Barstow Rail yard is the largest classification yard this side of the country, most goods being shipped by rail out of Southern California ports goes through here. Go back across the bridge and continue on mainstreet. It will cross under the 15, and then you can get on East 40.
If you want any additional information just ask. Hope you enjoy your trip!