% open the input file for read in = fopen('input.dat','r'); % open the output file for write out = fopen('Z:\Matlab-examples\results.txt', 'w'); % retrieve data from the input file and put them into vector y % the total number of values is in count [y, count] = fscanf(in, '%d', inf); % loop, calcuat all the height for i=1:1:count/2 % calcuate the v and t for height function v0 = y(2*i-1); t0 = y(2*i); % call the height function h0 = height(v0, t0); % write the value to the output file fprintf(out, '%f\n', h0); end % close the files we opened fclose(in); fclose(out);