MATLAB Answers

Getting a function I downloaded online to run

3 views (last 30 days)
Michael Vaughan
Michael Vaughan on 19 Sep 2020
Commented: John D'Errico on 20 Sep 2020
Hey guys, I'm extremly new to programming, so be patient with me!
and put it in a certain folder on my desktop, then used the addpath tool to add a path to this folder. I opened up the file in MatLab and the script appeared in an "editor window".
Now, if I type in intpartition(4) the output should be {[1 1 1 1],[1 1 2],[1 3],[2 2],4}
But instead it's saying
Undefined function or variable 'intpartition'.
What is the problem here? Did the addpath not work correctly? I find this strange because I got another program, nsumk, to run just fine, and they are in the same folder.
Thanks!

  0 Comments

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 19 Sep 2020
First, use dir on the folder to be certain it actually appears there.
Second, see what:
which('intpartition.m')
returns.

  4 Comments

Show 1 older comment
Michael Vaughan
Michael Vaughan on 19 Sep 2020
I have the file in my folder called "research," and then another copy of it in a folder called "Programs" that is itself in the folder "research. I added both of these folders via addpath and getting the correct path from my command prompt window
Star Strider
Star Strider on 19 Sep 2020
Run the path command from a script or the Command Window. It will tell you if those directories are part of the path. Your user file path components will be at the end of that list. (At least that applies to R2020b.)
John D'Errico
John D'Errico on 20 Sep 2020
If you added the folders using addpath, verify you did it properly. path will tell you that. And then, make sure you SAVED the path, so it will be there next time.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!