1

I use a DOS batch script to call the matlab Command Window (matlab -nodesktop -nosplash -noFigureWindows -r "myscript"), and the script relies on some functions in different folders, which are in my path.

When I run this, the matlab Command Window which is created cannot find one of these functions, saying 'undefined function or variable'. This function is definitely in my path in the full Desktop version of matlab, but the path loaded in the Command Window version does not have that folder in it.

Calling which pathdef gives the same file in both versions, and they both have the same contents, but calling p=path; gives different paths, with the Command Window version only having psychtoolbox folders and the '\Documents\MATLAB' folders, not the folder this function is in.

Do you know how to get the Command Window to use the same path as the Desktop Window?

  • I don't know how to use the same path as desktop version but you can set the path to anything you like on startup by creating a `startup.m` script (put it in `\Documents\MATLAB`) which gets executed on startup. Alternatively use `addpath` inside your script to add dependent locations to your path. – jodag Aug 03 '17 at 15:43
  • thanks. I'd hoped there was a way to sort it without adding to the path within the script as each computer I run it on has a slightly different path, so this seems like a good solution. Thank you – John Grogan Aug 07 '17 at 09:33

0 Answers0