The file "myfun.m" is missing the function keyword. It should look like
function f1 = myFun(X,Y)
[f1,f2] = myFun2(X,Y);
end
And myfun only returns f1, not both f1 and f2. If you want it to return both, you have to list both on the function line
function [f1, f2] = myFun(X,Y)
[f1,f2] = myFun2(X,Y);
end
The script "myscript.m" has an extra "end" at the end of the file. It's a script, not a function so it should not have an end. Actually functions don't even need "end" statements, and I never use them.
myscript.m should look like
X = [1 2; 4 5; 6 7];
Y = [8 9; 10 11];
f1 = myFun1(X,Y);
[f1,f2] = myFun2(X,Y)
f1 = X*Y;
f2 = pdist2(X,Y);
Note that myFun1() will not call myfun.m because it has a 1 at the end of it so you must have a myFun1.m file or else you'll get an error.
Best Answer