Re: Function to compares two arrays and returns indices where they are equivalent

On 3/20/2011 7:05 AM, Daniel Carrera wrote:
On 03/20/2011 12:30 PM, Nasser M. Abbasi wrote:
---- foo.m -----

function A()

function B()
-------- end foo.m -----------

As I understand Matlab, the function name matches the file name. If you
call function "foo()", Matlab searches for a file called "foo.m". Please

function B above is a subfunction and is visible only from the primary function (function A) above and indeed the file foo.m should be a.m as Matlab will ignore the internal name A and only call the function by the name 'foo' that is the m-file name.

The scoping rules in Matlab are unique; "if in Rome, one does as the Romans do" is the only way to think of it...

It's something that one gets used to with time and eventually (at least for me) isn't anything that even think about as being an issue. The more painful one is the naming conflicts w/ such a large number of basic keywords and when add a plethora of toolboxes namespace pollution is a major difficulty imo TMW hasn't a solution for.


Relevant Pages

  • Re: New behaviour with nested functions hiding builtins
    ... function precedence which describes this as intended behavior. ... over another based on the type of function and its location on the MATLAB ... overloaded methods that are on the path and have the same name. ...
  • Re: "include" a .m file into another .m file
    ... just call it like any other MATLAB function. ... If you're trying to call a subfunction in the second file from within your ... function s = createhandles ... If the other file is a script, just run it by typing the name of the script. ...
  • Re: Create function handle for subfunction in base
    ... I would like to call a subfunction from Matlab ... subfunction from Matlab base workspace? ... The mfile containing ...
  • Re: GUI run another GUI
    ... Another way of doing this under Matlab 7 is to pass the data to your GUI via a regular function call. ... Within GUI2.m there needs to be some subfunction 'GetData' of the following form: ... Obviously 'GetData' must know what to do with the input data ... ...
  • Re: Linear Algebra
    ... On 12/3/2010 8:31 AM, Daniel Carrera wrote: ... depending on what A looks like. ... "MATLAB Incorporates LAPACK" ...