Here is one solution. Define two files:
- Write a "template" Mfile, which is complete except for that line. On that line put a unique string, such as XXX.
- Write another "lines" file, containing every version of that replacement line that you want to use.
Then in a script, do these steps in a loop:
- Read one line of the "lines" file, e.g. newline = fgetl(..).
- Read the template file into a variable, e.g. str = fileread(..).
- Use string functions to find and replace that line, e.g. strrep(str,'XXX',newline).
- save the changed variable in a new file (remember it needs a new name).
Bingo! You will have all of your Mfiles /functions, identical except for that one line.
Best Answer