Hi Ian M,
I understand that you are facing difficulty in saving preferences as it keeps on resetting to default. MATLAB preferences are stored in a file named ‘matlab.prf’. This file is in MATLAB preferences directory, which varies depending on operating system. Here is a way to locate it:
- Open MATLAB
- Type ‘prefdir’ in the MATLAB command window and press Enter. This will display the location of MATLAB preferences directory.
This might be due to MATLAB not being able to properly save changes to the ‘matlab.prf’ file. It can occur due to several reasons such as lack of writing permissions, disk space, or unexpected MATLAB termination. Here are some steps to troubleshoot:
- Make sure to have write permissions for the directory containing the ‘matlab.prf’ file. On Windows, right-click the ‘matlab.prf’ file, select Properties, then Security. Check that the user account has written permissions.
- Ensure that there is enough disk space to save changes to the ‘matlab.prf’ file.
- Check if MATLAB closes properly. If MATLAB terminates unexpectedly (e.g., system crash, forced termination), it might not have a chance to save changes to the matlab.prf file.
- As a workaround, manually backup the ‘matlab.prf’ file. After setting the preferences, close MATLAB, navigate to MATLAB preferences directory, and create a copy of the ‘matlab.prf’ file. If the preferences are reset, restore them by replacing the ‘matlab.prf’ file with the backup.
The preference related to the command line you are referring controls the format of the output displayed in the MATLAB Command Window. The 'loose format’ includes blank lines to separate output lines, while the 'compact format’ does not. I understand currently the preferred option is the ‘compact’, but it keeps reverting to the default ‘loose’ option. The following steps can be used to troubleshoot and potentially fix the issue:
- Use the ‘format’ function in MATLAB scripts to programmatically set the output format to 'compact'. Simply add ‘format compact’ at the beginning of the scripts.
- Create a startup script that sets the output format to 'compact' every time MATLAB starts. Open MATLAB and type ‘userpath’ in the Command Window. MATLAB will return the path to the user directory. This is the directory where MATLAB will look for a ‘startup.m’ file each time it starts. Create a new script in the MATLAB startup directory, add the line ‘format compact’, and save the script as ‘startup.m’. Now, every time on starting MATLAB, it will run this ‘startup.m’ script and set the output format to 'compact'.
Please note that if a ‘startup.m’ file already exists in the startup directory, one should open it and add ‘format compact’ to it, rather than creating a new 'startup.m' file.
Kindly refer to the documentation links below for further information:
Hope it helps!
Best Regards
Simar