Matlab is in the wrong working path, how to set it?
40 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello,
i try to load a file, that is in the folder '/functions'
I tried to add this by addpath('\function) but this didnt work. Only addpath([pwd '/functions/']) works.
the command pwd and cs gives out the right directory but if i try to load the file it says:
Error using load
Unable to find file or directory 'C:\file.mat'.
It seems that the matlab is working in an other directory. I dont know how to change it.
I reinstalled matlab allready, but the prefferences are saved somewhere.
I also tried to set the paths(home/set paht) to default, didnt work
Can I set whole matlab to default?
Thanks for your help
5 Commenti
Stephen23
il 5 Ott 2022
Modificato: Stephen23
il 5 Ott 2022
"pwd gives out the directory the script is in. "
No, PWD gives the current directory. Whether the script is in the current directory or not is irrelevant to PWD.
"This folder includes the subfolder /function.."
There is no directory named FUNCTION in the LS output you show. But there is one named FUNCTIONS.
"but it is not possible to include this one by a relative path"
Why are you still attempting to use relative paths with ADDPATH?:
addpath('\xml_io_tools\');
Risposte (1)
Bjorn Gustavsson
il 5 Ott 2022
Generate full (or relative) path to the file you want to load:
data_dir = '/home/me/data';
data_file = 'mydata.mat';
file2load = fullfile(data_dir,data_file);
Load said file:
load(file2load)
Use the matlab-path for its intended purpose: expand the search-tree of toolboxes with matlab-functions.
HTH
0 Commenti
Vedere anche
Categorie
Scopri di più su Search Path in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!