title: Modify an Excel sheet from Matlab
body: <p>Is it possible to open a worksheet in excel from matlab and edit the formulas?  The idea is to automate an uncertainty analysis by creating a second sheet with the uncertainty in each cell for the value from the previous cell.  Essentially, I want to treat the cells as variables and do SQRT(SUM(Partials(xi)^2)) for each cell.  Matlab should have no problem with the calc, but can it edit the formulas in sheets?</p>
  
  <p>The process currently is to copy and paste from excel to matlab.  Here's a small function that does the uncertainty in matlab against on array of equations:</p>
  
  <pre><code>function [f_u_total f_u] = uncertAnalysis(f, vars, vars_u)
      f_u = [];
      f_u_total = [];
      for(i=1:length(f))
          f(i)
          item = uncertAnalysisi(f(i), vars, vars_u);
          f_u = [f_u; item(1)];
          f_u_total = [f_u_total; item(1)];
      end
  end
  
  
  function [f_u_total f_u] = uncertAnalysisi(f, vars, vars_u)
      f_u = [];
      % take the partials and square them
      for i=1:length(vars)
          f_u = [f_u; vars(i) (diff(f, vars(i)).*vars_u(i)).^2];
      end
      % calculate the RSS
      f_u_total = (sum(f_u(:,2))).^.5;
  end
  </code></pre>
  
  <p>As an aside, the equations look something like this (why I'm not doing this by hand):</p>
  
  <pre><code>=(9*C!S3^2/C!V3^4*C!W3*(C!O3-
  C!P3)/C!X3*C!Q3^6*C!F3^4/C!Y3^6/(C!U3^C!Z3)^6*F3^2+1/4*C!S3^2/C!V3^4*C!W3/(C!O3-
  C!P3)/C!X3*C!Q3^6*C!F3^6/C!Y3^6/(C!U3^C!Z3)^6*O3^2+1/4*C!S3^2/C!V3^4*C!W3/(C!O3-
  C!P3)/C!X3*C!Q3^6*C!F3^6/C!Y3^6/(C!U3^C!Z3)^6*P3^2+9*C!S3^2/C!V3^4*C!W3*(C!O3-
  C!P3)/C!X3*C!Q3^4*C!F3^6/C!Y3^6/(C!U3^C!Z3)^6*Q3^2+1/C!V3^4*C!W3*(C!O3-
  C!P3)/C!X3*C!Q3^6*C!F3^6/C!Y3^6/(C!U3^C!Z3)^6*S3^2+9*C!S3^2/C!V3^4*C!W3*(C!O3-
  C!P3)/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