Context : Being the most numerous and oldest stars in the galaxy , M dwarfs are objects of great interest for exoplanet searches . The presence of molecules in their atmosphere complicates our understanding of their atmospheric properties . But great advances have recently been made in the modeling of M dwarfs due to the revision of solar abundances . Aims : We aim to determine stellar parameters of M dwarfs using high resolution spectra ( R \sim 90 000 ) simultaneously in the visible and the near-infrared . The high resolution spectra and broad wavelength coverage provide an unique opportunity to understand the onset of dust and cloud formation at cool temperatures . Furthermore , this study will help in understanding the physical processes which occur in a cool atmospheres , particularly , the redistribution of energy from the optical to the near-infrared . Methods : The stellar parameters of M dwarfs in our sample have been determined by comparing the high resolution spectra both in the optical and in the near-infrared simultaneously observed by CARMENES with the synthetic spectra obtained from the BT-Settl model atmosphere . The detailed spectral synthesis of these observed spectra both in the optical and in the near-infrared helps to understand the missing continuum opacity . Results : For the first time , we derive fundamental stellar parameters of M dwarfs using the high resolution optical and near-infrared spectra simultaneously . We determine T _ { \mathrm { eff } } , \mathrm { log } g and [ M/H ] for 292 M dwarfs of spectral type M0 to M9 , where the formation of dust and clouds are important . The derived T _ { \mathrm { eff } } for the sample ranges from 2300 to 4000 K , values of \mathrm { log } g ranges from 4.5 \leq \mathrm { log } g \leq 5.5 and the resulting metallicity ranges from -0.5 \leq [ M/H ] \leq +0.5 . We have also explored the possible differences in T _ { \mathrm { eff } } , \mathrm { log } g and [ M/H ] by comparing them with other studies of the same sample of M dwarfs . Conclusions :