I think I am 80% all the way there, but cannot get the txt file with data for 421 files. If I run the following code, txt file takes the output only for sec, and rewrite it over and final output is only for last step. Please let me know what I have done wrong
format long
numfiles =421;
mydata = cell(1,numfiles);
for k = 1:numfiles
myfilename = sprintf('side20m0%d.csv',k-1); mydata{k} = cell(1,numfiles);
x_location = importfile(myfilename);
temp = importfile1(myfilename);
deriv = zeros(502,1);
for j=1:502
if j<502
deriv(j) = (temp(j+1)-temp(j))/(x_location(j+1)-x_location(j));
else
deriv(j) = 0;
end
end
M = [deriv,x_location];
[minA loc] = min(M(:,1));
xAtMin = zeros(420,1);
xAtMin(k) = M(loc,2);
fileID = fopen('Result.txt','w');
fprintf(fileID,'%6.6f\n', xAtMin(k));
fclose(fileID); end