This paper deals with the problem of mobile-robot localization in structured environments. The extended Kalman filter (EKF) is used to localize the four-wheeled mobile robot equipped with encoders for the wheels and a laser-range-finder (LRF) sensor. The LRF is used to scan the environment, which is described with line segments. A prediction step is performed by simulating the kinematic model of the robot. In the input noise covariance matrix of the EKF the standard deviation of each robot-wheel's angular speed is estimated as being proportional to the wheel's angular speed. A correction step is performed by minimizing the difference between the matched line segments from the local and global maps. If the overlapping rate between the most similar local and global line segments is below the threshold, the line segments are paired. The line parameters' covariances, which arise from the LRF's distance-measurement error, comprise the output noise covariance matrix of the EKF. The covariances are estimated with the method of classic least squares (LSQ). The performance of this method is tested within the localization experiment in an indoor structured environment. The good localization results prove the applicability of the method resulting from the classic LSQ for the purpose of an EKF-based localization of a mobile robot.