Current folder is wrong after starting from command line. Why? How to fix it?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Matlab has a nifty feature: When started from (Windows) command line, it takes the current directory from there. With my installation that fails. During initialization it is correct, as can be seen in the directory window. But at the end of initialization it switches to the standard folder! THEN it runs the -r option and cannot find the referenced m-script file.
Why is that so? How to fix it?
By the way, is there any way to let a running instance of Matlab run a m-script from (Windows) command line, instead of letting a new instance open?
0 Commenti
Risposta accettata
Jan
il 7 Ago 2013
Does the switch to the standard folder happen inside a user-defined startup.m function?
Here you find a description of the troubles I had, when I had started Matlab from another Matlab session and the parent folder of strncmp.m was the current folder in the caller. This means, that the folder is kept initially and the userpath is activated later on.
A solution might be to cd to the wanted folder:
system('matlab -r "cd(''C:\Temp''); yourFunction" &')
0 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Startup and Shutdown in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!