title: How to use eval in Matlab R2013a to replace a symbolic var s to the tf('s')
body: <p>I created a multiple feedback second order lowpass filter that amplifies and also adds a dc reference to the output.</p>
  
  <p><img src="https://i.stack.imgur.com/5cGdk.png" alt="Differencial seconde order multiple feedback lowpass filter"> </p>
  
  <p>To simulate it, I created the code below that used to work in a previous MATLAB version. Now in the 2013a version, it's not working any longer.</p>
  
  <pre><code>clear all
  close all
  
  syms s Rf R1 R2 C1 Cf Vref V2 V1
  
  Zf1 = R2+1/s/Cf;
  Al1 = [(1/Zf1+1/Rf+1/R1+s*C1) (-s*C1) (0)];
  Al2 = [(-s*C1) (1/Zf1+1/Rf+1/R1+s*C1) (-1/Zf1-1/Rf)];
  Al3 = [(-1/Zf1/s/Cf) (1/Zf1/s/Cf) (-1/Zf1/s/Cf+1)];
  A = [Al1; Al2; Al3];
  
  B = [(Vref*(1/Zf1+1/Rf)+V2/R1) ;(V1/R1) ; (Vref*(1-1/Zf1/s/Cf))];
  V=A^-1*B;
  
  Vo = simplify(V(3));
  Vo = collect(Vo,Vref);
  pretty(Vo);
  
  %damp = sqrt(2)/2;   % butterworth filter
  %wc = 2*pi*150;
  %coef_s = 2*damp/wc;
  
  fc = 150;
  [z,p,k] = butter(2,1,'low','s');
  
  modpole = abs(p(1));
  alpha = abs(real(p(1)));
  damp = alpha/modpole;   
  
  wc = 2*pi*fc*modpole;
  coef_s = 2*damp/wc;
  
  Gain_0Hz = 4.7;
  
  clear syms
  R1 = 1E3
  Rf = Gain_0Hz*R1
  Cf = 82E-9
  
  R2calc = solve('Cf*(Rf*R2/R1+R2+Rf)=coef_s',R2);
  R2 = eval(R2calc)
  
  C1calc = solve('2*C1*Rf*R2*Cf=1/wc^2',C1);
  C1 = eval(C1calc)
  
  Hs = (Vo - Vref)/(V2-V1);
  Hs = simplify(Hs);
  pretty(Hs);
  s = tf('s');
  numHs = eval(Hs);    % ofending command, should replace sym s by tf('s') as previous versions.
  bode(numHs);
  </code></pre>
  
  <p>Unfortunately, after I upgraded to the 2013a MATLAB, this code stopped working.
  The error shown is:</p>
  
  <pre><code>Error using evalin
  Undefined function 'power' for input arguments of
  type 'tf'.
  
  Error in sym/eval (line 11)
  s = evalin('caller',vectorize(map2mat(char(x))));
  </code></pre>
  
  <p>After applying the fix from @Fija, the normal operation was recovered.
  And the results are shown below:</p>
  
  <pre><code>  Vref - (Rf V1 - Rf V2) / (R1 + Cf R1 R2 s + Cf R1 Rf s + 
  
                                      2 
       Cf R2 Rf s + 2 C1 Cf R1 R2 Rf s )
  
  R1 =
  
          1000
  
  
  Rf =
  
          4700
  
  
  Cf =
  
     8.2000e-08
  
  
  R2 =
  
     2.3858e+03
  
  
  C1 =
  
     6.1218e-07
  
  
    Rf / (R1 + Cf R1 R2 s + Cf R1 Rf s + Cf R2 Rf s + 
  
                         2 
       2 C1 Cf R1 R2 Rf s )
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/227kW.png" alt="Bode diagram of resulting filter"></p>