Trinh @ Bath

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
it_matlab_startup [2024/03/23 23:19]
trinh
it_matlab_startup [2024/03/23 23:35]
trinh
Line 4: Line 4:
  
 Run this command to open the startup file Run this command to open the startup file
 +
 +<code matlab>
 +edit(fullfile(userpath,'startup.m')) </code>
 +
 +
 +Once you have run the above, the relevant startup file should appear. You can copy and paste the below as a starter. Comment in or out the relevant scripts. 
  
 <code matlab 1> <code matlab 1>
-edit(fullfile(userpath,'startup.m')) +% Example startup file  
- </code>+ 
 +% This adds all paths recursively from the directory 
 +% You can add the relevant directory where you store commonly used functions  
 +% On windows, you may need to use a directory structure like C:\Users\myuserid\Documents\... 
 +% addpath(genpath('~/myfunctions')); 
 + 
 +% This adds a single path 
 +% addpath ~/mysinglepath/ 
 + 
 +% Set figure default to something more pragmatic 
 + 
 +colordef white 
 +set(0, 'Units', 'pixels'); 
 + 
 +set(0, 'defaultaxesfontsize', 18, 'defaultaxeslinewidth', 1, ... 
 + 'defaultlinelinewidth', 1, 'defaultpatchlinewidth', .7, ... 
 + 'defaultAxesFontSize', 18)
 + 
 + 
 +set(0,'DefaultFigureColor','w', ... 
 + 'DefaultAxesColor','w',... 
 + 'DefaultAxesXColor','k',... 
 + 'DefaultAxesYColor','k',... 
 + 'DefaultAxesZColor','k',... 
 + 'DefaultTextColor','k',... 
 + 'DefaultLineColor','k')
 + 
 +clear 
 +close all 
 + 
 +% Add the starting path 
 +% cd ~/mystartingpath/ 
 +</code>
  
 +You can try running the script. 
  
- % Example startup file  +If you exit Matlab and restart it, Matlab should run the startup script automatically
-  +
- % This adds all paths recursively from the directory +
- addpath(genpath('~/myfunctions')); +
- % This adds a single path +
- addpath ~/mysinglepath/ +
-  +
- % Set figure default to something more pragmatic +
-  +
- colordef white +
- set(0, 'Units', 'pixels'); +
-  +
- set(0, 'defaultaxesfontsize', 18, 'defaultaxeslinewidth', 1, ... +
-         'defaultlinelinewidth', 1, 'defaultpatchlinewidth', .7, ... +
-         'defaultAxesFontSize', 18); +
-  +
-  +
- set(0,'DefaultFigureColor','w', ... +
-       'DefaultAxesColor','w',... +
-       'DefaultAxesXColor','k',... +
-       'DefaultAxesYColor','k',... +
-       'DefaultAxesZColor','k',... +
-       'DefaultTextColor','k',... +
-       'DefaultLineColor','k'); +
-  +
- clear +
- close all +
-  +
- % Add the starting path +
- cd ~/mystartingpath/+