Question

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
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top