I would like to be able to run a function from the directory where it is defined. Let's say this is my folder structure:
./matlab ./matlab/functions1 ./matlab/functions2
and I have all the directories in my MATLAB path, so I can call the functions that are in these directories.
Say my function "func" is in "matlab / functions1". My function contains a command
csvwrite('data.csv', data(:));
Now, if I call "func" from. / matlab, "data.csv" is created in. / matlab. If I call him out. / matlab / functions 2, it will be created in this directory. But I would like the function to always write "data.csv" to the directory where the function is defined (./matlab/functions1), regardless of what my current directory is. How can i achieve this?
source share