No, Barcelona is not better than Madrid instead both the cities are quite different. Madrid will offer you the best of Spanish experiences with its traditional culture, historic sites and classy museums.
Barcelona on the other hand offers a hands-down European experience with its fantastic nature and finest beaches.