0

How do I define two functions

function [Y,Ytheta,Yphi] = spharm(n,m,theta,phi)
function [A,B] = matchsize(A,B)

in the same MATLAB .m file?

Alternatively, can I save them as two different MATLAB files (.m files) which will talk to one another?

m_power
  • 3,156
  • 5
  • 33
  • 54

1 Answers1

0

you can have multiple functions in one file but you have to remember that only the first function in the file is normally "visible" to functions outside the file. If you need auxiliary functions for your main function, define them in the same .m.

btw: there are ways to get access to other functions in the file using function handlers.

dlavila
  • 1,204
  • 11
  • 25