I’m quite new to Matlab. I’ve defined a function inside a .m file, I want to use that function in that .m file inside another .m file, and I want to run the contents of that last .m file from the command window.
How should I go about accomplishing this?
EDIT– for clarification, I have one function a inside a.m, and a script inside b.m that uses the function a inside a.m. I would like to run this script inside b.m from the command window, but am not sure how to do so. (as a side note, I can totally convert the script in b.m into a function if need be)
EDIT– right now I just need to know how to import/load a matlab file and that is it!!!
In principle, MATLAB advocates the use of one function per
.mfile. You can call such a function from another.mfile and from the MATLAB command line.You can define multiple functions in one
.mfile, but only the first (or ‘outermost’) function can be accessed from other.mfiles or the command line. The other functions are treated as ‘helper’ functions that may be called only inside this particular.mfile.