Animation Help!

So i have this animation but i wanted to know how to apply it to my walk script. The last code i used it said that the animation could not be played because it could not be found. But anyways here is the script, please help, thanks!

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour
{
	public bool controllable = true;

	public float speed = 7.0f;
	public float jumpSpeed = 6.0f;
	public float gravity = 20.0f;


	private Vector3 moveDirection = Vector3.zero;
	private CharacterController controller;

	// Use this for initialization
	void Start()
	{
		controller = GetComponent<CharacterController>();
	}

	// Update is called once per frame
	void Update()
	{
		if (controller.isGrounded && controllable)
		{
			moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
			moveDirection = transform.TransformDirection(moveDirection);
			moveDirection *= speed;

			if (Input.GetButton("Jump"))
				moveDirection.y = jumpSpeed;

		}
		moveDirection.y -= gravity * Time.deltaTime;
		controller.Move(moveDirection * Time.deltaTime);
	}
}

using UnityEngine;
using System.Collections;

 public class PlayerController : MonoBehaviour
 {
     public bool controllable = true;
 **public Animator anim;**
     public float speed = 7.0f;
     public float jumpSpeed = 6.0f;
     public float gravity = 20.0f;
 
 
     private Vector3 moveDirection = Vector3.zero;
     private CharacterController controller;
 
     // Use this for initialization
     void Start()
     {
         controller = GetComponent<CharacterController>();
     }
 
     // Update is called once per frame
     void Update()
     {
         if (controller.isGrounded && controllable)
         {
             moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
             moveDirection = transform.TransformDirection(moveDirection);
             moveDirection *= speed;

**anim.setFloat("yourvariablename",moveDirection);**
             if (Input.GetButton("Jump"))
                 moveDirection.y = jumpSpeed;
 
         }
         moveDirection.y -= gravity * Time.deltaTime;
         controller.Move(moveDirection * Time.deltaTime);
     }
 }

you have to define moveDirection in animator in transition from any state to walk that if moveDirection is greater than 0.1 than transit to walk animation and in return moveDirection is less than 0.1.