MATLAB: Hi I would like to ask how to call or add a function in mfile in another script file. I am using matlab 2013a. thank you

functionneural networkscript

I used the neural network toolbox to generate an mfile then i make it as a function. then i would like to call or add it in another script where i would use the function. I dont know how to call or include the generated mfile in the other script file.

Best Answer

say your function is defined in a file abc.m, and the name of the function is abc(),
then you can call abc() in any of your other functions by just calling abc() in your code. The only precondition is that abc.m must be in path.
Eg: File1 abc.m
function z=abc(x,y)
z=x+y;..
File2 something.m
result = abc(1,2)% function abc is called here.