- use a higher quality device with a stronger magnetic field
- have the device calibrated by experts
- make sure that the room with the device is well shielded magnetically and from vibration
- if you are not using a system that is evolving quickly, scan multiple times in order to reduce noise
The only one of those which can involve MATLAB is the last one, taking multiple scans and averaging them to reduce noise. Other than that, you cannot use MATLAB to improve the quality of MRS.
Source: I used to write software to analyze MRS, for a research institution. Some of my co-workers were considered world leaders in designing new MRI and MRS. There were some very interesting things that could be done at the hardware level, and in control of the devices... but once we had the DICOM files, there was no way to improve the quality of the MRS.
The limit of what could be done in MATLAB was to improve the quality of interpretation of the MRS.