Environment setup - epfl-lasa/wiki GitHub Wiki

Intro

Matlab can sometimes be annoying because you have to manually add folders to the search path. Here is a script that you can run once and does all that for you cleanly. It works no matter from where you invoke it and doesn't necessitate absolute path.

Code

%% Environment setup

% Classique matlab clean 
clear all; clc; close all;

% Record initial folder
initial_folder = pwd();

% Find the current file location so we can use relative paths
here = mfilename("fullpath");
here = here(1:end-length(mfilename));

% Add function folder + full env
addpath(genpath(strcat(here, "functions")));
addpath(genpath(strcat(here, "external_ressources")));
% ... add as much paths as you need here