1

I have placed a MATLAB script "x.m" in the path of my current working directory. So the script is in folder "~/a" and my working directory is "~/a/b" But MATLAB seems to be not recognizing that the single function 'x' in the script exists? I have named the file exactly the same as function, which works properly when I place the script in my exact working directory rather than just on the path of my working directory. I believe my version is MATLAB2016a, if that makes any difference. Before updating to MATLAB2016a, I had made a similar function and was able to use it properly with just putting the script in the path of my working directory.

Suggestions/solutions?

3
  • 1
    You can't just have a function in the parent directory and expect MATLAB to find it. There is a thing called the MATLAB path, which is the collection of directories MATLAB will search to find functions. You can add directories to it using addpath. Commented Feb 10, 2018 at 22:00
  • @CrisLuengo that makes sense, though that's exactly what I have done in the past. (I really don't like MATLAB and ought to just switch back to a full programming language at some point.) Thanks for the comment. I'll accept it as the correct answer if you want to post it as an answer! :) Commented Feb 10, 2018 at 22:02
  • 1
    That worked! Thanks so much! Now I just have a "matlab_stuffs" folder which is for all my matlab functions. This will work great for me. Commented Feb 10, 2018 at 22:06

1 Answer 1

1

You can't just have a function in the parent directory and expect MATLAB to find it. There is a thing called the MATLAB path, which is the collection of directories MATLAB will search to find functions. You can add directories to it using addpath.

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

Comments

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.