clear all; d=dir('*jpg.csv'); for k=1:length(d); fname=d(k).name; counts = dlmread(fname,'\t',1,0); counts(end,:)=[]; counts(:,end)=[]; % from 10:end because it has sigmoidal shape screwing things up [m, R, idiv, G] = regress2lines(counts(10:end,3),counts(10:end,4)); xy = [1, m(5); (m(1)*1+m(2)), (m(1)*m(5)+m(2)); m(5), 40; (m(3)*m(5)+m(4)), (m(3)*40+m(4));]; store_fname{k,1} = fname; store_intercept(k,1) = m(5); store_count(k,1) = exp((m(1)*m(5)+m(2))); % subplot(1,length(d),k) hold off plot(counts(:,3),counts(:,4),'bs') hold on plot(xy(1,:),xy(2,:),'b-') plot(xy(3,:),xy(4,:),'r-') title({fname}); drawnow pause end fid = fopen('output.csv','a'); for k=1:length(store_fname); fprintf(fid,'%s\t%0.5g\t%0.5g\n', store_fname{k}, store_intercept(k), store_count(k)); % sprintf('%s\t%0.5g', store_fname{k}, store_intercept(k)) end