%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Author: Matthew Brukman, Engineering Physics Department, University of %Wisconsin-Madison %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function batchfd_new(file_name,endno) close all clc %Reads DI Force-Distance files starting from 'filename' and ending with %'endno' and returns a matrix g containing the "Sens Deflection" and pulloff %voltage for each file. Also creates a text file with labeled column %headings containing the same. % Ask user to select the first file [file_name,path,ext] = uigetfile(pwd,'Select first file','*.*'); % Ask user for extension of last file prompt = {'What is the extension of the last file?'}; title = 'Last file number'; lines= 1; def = {'10'}; last = inputdlg(prompt,title,lines,def); endno = str2num(last{1,1}); %Determine the name of the first file (without the extension) and the %extension of the first file (as a string) [pathstr,name,ext,versn] = fileparts(file_name); no1 = str2num(strrep(ext,'.','')); %create output matrix g = []; figure; for (n = (no1):endno) index = num2str(n); if (n < 10) new_ext = strcat('00',index); elseif (n >=10) & (n < 100) new_ext = strcat('0',index); elseif (n >= 100) new_ext = index; end full_name = strcat(path,name,'.',new_ext); %Run getfd1 and append successive outputs of that program to the %output matrix A = getfd_new_oldNanoscope(full_name); g = [g;A]; disp(num2str(n)); end disp(['The pull-off deflection = ', num2str(mean(g(:,3))),' +- ', num2str(std(g(:,3))), ' nm']); %Create text file with name format basename-1st file #last file#.txt %eg m040609-001-010.txt from usage example above new_file = fullfile(path,[name '-' num2str(no1) '-' new_ext '.txt']); %Add data to output text file fid = fopen(new_file,'w'); label = ['slope(V/nm) ' 'pull-off(V) ' 'pull-off(nm) ' 'max_defl(nm)' ]; fprintf(fid,'%s\r',label); fprintf(fid, '%4.4d %4.4d %4.4d %4.4d\r', g'); fclose(fid); fclose('all');