The naming used here as function1
, Root
, class1
and class2
are just fictitious and does not exist in the code. They are just here to mask their real names, however they explicily represent how the files are disposed on the files system and how they are being called.
- There are folders called
Root
,Root/class1
andRoot/class2
. - There are the files called
Root/class1/function1.m
andRoot/class2/function1.m
. - On these files there are the functions
function function1( A )
andfunction function1( A, B )
, respectively.
Now I am on the folder Root/class2
running a file called system.m
and I do:
addpath( '../class1' )
function1( A )
And it tries to call the function function1( A, B)
from the file Root/class2/function1.m
instead of call the function function function1( A )
from the file Root/class1
, outputting the error:
error: 'B' undefined near line 4 column 27
How to call the function function function1( A )
from the file Root/class1/function1.m
while running a file from the folder Root/class2
overloading the function within the current "context"?
I want to call a function from another folder, but over there, it has the same name as a function within the current folder.