I am looking for a way to write a script file in MATLAB that generates a sequence of functions and save them each in a separate m-file.
More precisely, suppose you have a script file and you want to generates N different functions; something like this:
for i=1:N
Step 1: Do some symbolic calculation and find the expression of fi
Step 2: Define the function fi=fi(...)
Step 3: Save the the function in an m-file say fi.m
end
I myself have not found any clue so far. Here is two questions that if answered, such code then follows straightforwardly:
1. How to define a function in a script file and automatically save it in an m-file: Let say y=f(x)=x^2 is a symbolic relation calculated in a script file; how to automatically generate a function for it and save it in an m-file
2. How to use a string as a file name, function name, etc: Suppose you are creating an string "fi" in a loop for every i, and you want to use this string as a function name
Thanks for your help in advance