1

There is a script myScript.m, under D:\myProjects, so its location is D:\myProjects\myScript.m

I want to load a .dat file at D:\myProjects\myData\someData.dat

How do I use the load() function without using the absolute path like

data = load('D:\myProjects\myData\someData.dat')   % something I do not want
tshepang
  • 12,111
  • 21
  • 91
  • 136
Nick X Tsui
  • 2,737
  • 6
  • 39
  • 73
  • 1
    Have a look [here](http://blogs.mathworks.com/pick/2011/04/01/be-absolute-about-your-relative-path-with-getfullpath/). – Marcin Feb 06 '14 at 01:38

1 Answers1

2
data = load('myData\someData.dat')   

Use a relative path. This assumes you are executing the program from it's home directory D:\myProjects.

If you need to call the script from different folders you should pass the path to the .dat as an argument to the script.

jeremyjjbrown
  • 7,772
  • 5
  • 43
  • 55