A general example of how a main program and functions should be set up ---------------------------------------------------------------------- process_data.m main program fcalcQ.m custom functions called by main program fread1col.m fwrite1col.m datafile1.dat input data datafile2.dat y.dat output data (generated by process_data.m) NB all files must be in same directory, so matlab knows where to find things. (Alternatively, place *.m files in your 'programs' directory.) To run in matlab >> process_data