MATLAB Answers

How do I run a function I downloaded?

1 view (last 30 days)
Michael Vaughan
Michael Vaughan on 18 Sep 2020
Commented: Michael Vaughan on 19 Sep 2020
So I downloaded this script nsumk to do some cool partition of integers for me:
When i open it in matlab it appears in the editor window, I think it's like in the place where I would normally write scripts (once I get that advanced, haha!). Anyway, what do I have to do from here to get this functiln nsumk running in my command line?? I've tried typing in numk and stuff like that but can't get it to work.
If you can't tell, i'm a total scrub at this stuff, but i'm very interested!!
Simple explanations appreciated!! Peace out!!!!


Sign in to comment.

Answers (1)

Mario Malic
Mario Malic on 18 Sep 2020
Edited: Mario Malic on 18 Sep 2020
Please see John's comment as it's important.
Place the function in your current folder and call it from command window, or in write it in script.
[m,x] = nsumk(n,k)


Show 5 older comments
Walter Roberson
Walter Roberson on 19 Sep 2020
You need to either have defined n and k already as variables, or else pass in particular numeric values.
n = 7; k = 4;
[m, x] = nsumk(n, k);
[m, x] = nsumk(7, 4);
Michael Vaughan
Michael Vaughan on 19 Sep 2020
I put:
>> n = 7; k = 4;
[m, x] = nsumk(n, k);
into the command prompt and get this:
Error: File: nsumk.m Line: 11 Column: 53
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To
construct matrices, use brackets instead of parentheses.
Thx for being patient with me
Michael Vaughan
Michael Vaughan on 19 Sep 2020
Weird, I went to that line and put a % at the start of it, now the program runs, Thx

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!