title: Extracting data and do calculation from multiple CSV file and compile the calculation values into one file
body: <p>I have written a code for extracting data from a single csv file and performing a set of calculation to output 1 result. What I want to do is I will like to be able to running this file over a set of 20 csv raw data files, perform the calculation to get the results for each files and compile all these results into a single matrix.</p>
  
  <p>for example, at the end, I will have a 20 by 1 matrix , with each row representing the result from each csv files for 20 csv raw files.</p>
  
  <p>Here is the matlab code so far for a single file.</p>
  
  <pre><code>filename = 'some_file.csv'
  delimiter = ',';
  startRow = 19;
  formatSpec = '%*s%*s%f%f%[^\n\r]';
  fileID = fopen(filename,'r');
  dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'EmptyValue'      ,NaN,'HeaderLines' ,startRow-1, 'ReturnOnError', false);
  fclose(fileID);
  
  % extracted data into variable time and v
  
  time = dataArray{:, 1};
  v = dataArray{:, 2};
  
  clearvars filename delimiter startRow formatSpec fileID dataArray ans;
  
  % Start of calculation
  
  I = v.*2000; % sensitivity 0.5mA/V
  I_2 = I.^2;
  current_parameter = trapz(time,I_2);
  
  % Parameters, would like to set this up as input with 4 variable
  h = 25; 
  w = 5;  
  t = 2;  
  L_prime = 0.794193406;
  
  %Results
  Ibit(1) = 0.5*current_parameter*L_prime
  
  end
  </code></pre>
  
  <p>What I want is that I will like to run this files in a loop and call as a function where i can input specific parameters (4 variables) for each set of csv files. the result is the Ibit where 1 Ibit correspond to 1 csv file. I would like to compile this variable for the set of files i have.</p>
  
  <p>Thanks for the help in advance.</p>
  
  <p>Alan</p>