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
1
  • 1
    Have a look here. Commented Feb 6, 2014 at 1:38

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

What if not running from its home directory? It is a script, not really a function
This is not working ! I have just checked that on Matlab R2012b !
Can you put what you are doing into a pastebin or something? We need more info to help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.