It seems like that you could benefit from going through the "Getting Started" portion of the MATLAB document.
If both are M-scripts, not M-function, you could simply add "file1" without the quote at the first line of file2.m. It will execute file1.m and then the rest of file2.m. All the variables in file1.m will be in the MATLAB base workspace and thus available to file2.m too.
Depending on your release you can get the complete names including the path from dbstack (in v6.5 you couldn't, but already since v7.0 you can). As the doc describes:
dbstack(___, '-completenames')
outputs the fully qualified name of each function in the stack.
Best Answer