Pedestrian dead reckoning (PDR) is widely used in handheld indoor positioning systems. However, low-cost inertial sensors built into smartphones provide poor-quality measurements, resulting in cumulative error which consists of heading estimation error caused by gyroscope and step length estimation error caused by an accelerometer. Learning more motion features through limited measurements is important to improve positioning accuracy. This paper proposes an improved PDR system using smartphone sensors. Using gyroscope, two motion patterns, walking straight or turning, can be recognised based on dynamic time warp (DTW) and thus improve heading estimation from an extended Kalman filter (EKF). Joint quasi-static field (JQSF) detection is used to avoid bad magnetic measurements due to magnetic disturbances in an indoor environment. In terms of periodicity of angular rate while walking, peak–valley angular velocity detection and zero-cross detection is combined to detect steps. A step-length estimation method based on deep belief network (DBN) is proposed. Experimental results demonstrate that the proposed PDR system can achieve more accurate indoor positioning.