I've met very motivated people in my life, many of which are creating amazing things and companies. The first characteristic you can see in all these people is that they all have a well defined end goal. That's the first thing everyone should look for when motivating themselves, finding an end goal. This is essentially a long term goal, not short term ones. It must be a single goal, not a set of goals, else you will loose focus. I can hear you thinking already, "but I want to do so much", but that's the beauty of this end goal, it can be broad enough to cover all your dreams. This is the hardest question to answer ("what's my purpose in this life?"), took me 15 years (from the day I started to think about this, when I was a kid) to decide on what I wanted to do with my life, but the more life experience you have, the easier it is to decide upon it. When deciding on this, make sure you don't confuse the end with the means to reach it, so don't choose a specific goal such as become a doctor, or become the president of your country. Do you want to be a doctor, or do you want to actually save lives? Do you want to be the president, or do you want to build a better country/world? A tip that can help you with not confusing the end with the means is: state your end goal in 3 words or less. I can state mine in 2.
The second characteristic motivated people have is confidence. They are usually pretty confident they can reach their end goal. This is one of the reasons people have very different goals. Many would say that making the world better is a good goal, but how many would say they got the confidence to do it? If you don't have the confidence, build it. A little example from my own experience: when a kid I was scared of skating down a big half-pipe from a park we used to go to. At that time, my goal was quite simple, have fun and skate better than my friends, but I didn't really have the confidence to accept the challenge of skating down that huge half-pipe. I built up my confidence by going down smaller ones (even broke an arm when doing that, but it didn't stop me, I learned from my mistake and started using gloves) until one day I was confident enough to try going down the large one, and so I did. That's how you build confidence.
Lastly, after choosing your goals and building the confidence to do it, you need to decide on what way to take. For any goal, there are a wide choice of ways you can take to move towards them. Some ways are easier than others, some are more interesting, some are very challenging. This is what will define your short and mid term goals. Think of them as stepping stones so you can reach the end goal. Let's go back to one of our examples, you want to save lives. You can be a doctor and save lives, you can be a scientist, finding cures to diseases in a lab and save lives, you can be a fireman and save lives or even be an investor in nanotechnology labs and save lives. Which way is more appealing to you? Let's continue, you decided that by being a doctor you will save lives. First of all, what kind of doctor do you want to be? A cardiologist? A neurosurgeon? An E.R. doctor? Well, do you need to make that decision now? Not really, you can choose it while you are at college, so let's move on. Oh, right, you must enter college and graduate before becoming a doctor. Uhm, do you want to enter the best college you can? Damn, we need to study for the SAT then (I ain't American, not really sure how college admissions really work). Anyway, this is how you decide on the way. You state your end goal and work backwards from the longest term goal to the shortest one. That's how you decide on what means you will use to reach your end goal.
Anyway, after deciding on all that, that's how you will be motivated to study for that algebra exam, or to pay attention at that physics class from that boring teacher at 6pm on a Friday. A couple important notes, I highly suggest you to never share your end goal with your peers. This usually undermines your confidence, and therefor, your motivation. Secondly, your goal, once defined shouldn't change. If it changes, it just mean you haven't found yours yet. What can change, and should change (due to changes in environment) are the means you choose to take. The means can always change, but they should always be moving you towards the end. An example, your country enters in war. This is highly disruptive to everyone's lives and this will very likely affect on the means you will choose to reach your goal, but shouldn't change your end goal.