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()
...
end

function B()
...
end
-------- 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
explain.
....

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.

--
.