Use a script to pass parameters to and run another script file
Ben Abbott
bpabbott at mac.com
Tue Dec 30 16:50:11 CST 2008
On Dec 30, 2008, at 5:25 PM, babelproofreader wrote:
>
> I have a script file that reads data from a text file, performs some
> operations on the data and writes the results out to another text
> file. This
> operation needs to be run many times, each time using a different
> data text
> file and writing the results out to separate "results" text files.
> Is there
> a way in which the above script file can be run from a second script
> file,
> this second script file passing the name of the required data text
> file to
> be read prior to operations, and indicating the text file name that
> the
> results should be saved as?
Your first script file would be
-----------------------------
file_to_read = "data.txt"
file_to_write = "results.txt"
process_data (file_to_read, file_to_save)
-----------------------------
Your second function script would be
-----------------------------
function process_data (file_to_read, file_to_save)
.
.
.
endfunction
-----------------------------
Place your script between the function/endfunction lies and save the
second function script with the name "process_data.m". You can use a
different name, but be sure to change the function name (1st line) as
well.
Is that what you'd like to do?
Ben
More information about the Help-octave
mailing list