Reading input m-file in a main m-file
matlab
Solution
This is typically not good practice in MATLAB. The file containing the input variables would, in your example, be a script. As would your main file. MATLAB does not error when running one script from another, as suggested by ScottieT812, but under certain circumstances strange errors can arise. (Run time compiling has difficulty, variable name collisions across scripts)
A better option is to turn the inputs script into a function which returns the variables of interest
function [a,b c] = inputs
a = 5;
b = 6;
c = 7;
Then this function can be called in the main.m script.
% main.m
[a,b,c] = inputs;
s = a+b+c;
Problem
I would like MATLAB to tell me if I have an input file (.m file) that contains some variables with their numbers (i.e., `a = 5`, `b = 6`, `c = 7`) so that I can then use that .m file in another program (main .m file) that uses these variables to calculate `S = a + b + c`. How can I then read the input file from the main file? Assume the input file is called INP and the main MAIN.