user570593
user570593

Reputation: 3510

Execute a MATLAB file from code

How can I execute a MATLAB file (say "text1.m") from another MATLAB file ("main.m")?
I tried MATLAB's eval function but it didn't work:

evalc('K:\DOWNLOADS\experiments\bag_of_words\config_file_1.m');

Upvotes: 1

Views: 644

Answers (2)

Amro
Amro

Reputation: 124543

If the M-file is not on the path, there is a convenience function RUN to run scripts.

Upvotes: 1

O. Th. B.
O. Th. B.

Reputation: 1353

If it is a script you can directly call it using its filename (without ".m") in another M-file script (similar to a function-call without any arguments or parentheses). If it declares a function it should be in the MATLAB search path or in the current folder for you to be able to call the function. This is likely also the case for scripts.

Upvotes: 3

Related Questions