In this paper, a design and optimization procedure based on the method of least squares is presented for edge-coupled or parallel coupled-line filters, with impedance matching of arbitrary source and load impedances. An error function is constructed for the implementation of specified insertion loss in the passband and return loss in the stopband, based on the even- and odd-mode theory using the impedance, transmission and scattering matrices. The minimization of error function is performed with respect to the lengths, widths and gap spacings of lines, which determines the filter configuration. Computer implementation of the proposed method, comparison with the available full-wave analysis softwares, fabrication, and testing of sample filters, indicate the ease of application and advantages of the proposed method over the other methods (such as impedance matching, increasing bandwidth, and ease of computer implementation)