Ocs package: Difference between revisions

1,086 bytes added ,  22 September 2015
Line 618: Line 618:


<math>
<math>
b(z) = \dfrac{\partial c}{\partial z}
b(z) = \dfrac{\partial c}{\partial z} =
\left[
\left[
\begin{array}{c c c}
\begin{array}{c c c}
Line 629: Line 629:


The resulting model implementation is the following
The resulting model implementation is the following
{{Code| memristor model implementation|<syntaxhighlight lang="octave">
function [a,b,c] = Mmemristors (string, parameters, parameternames,
                                extvar, intvar, t)
 
  if isempty(intvar)
    intvar = 0;
  endif
  switch string       
    case "STRUKOV"
      ## NLC part
      for ii=1:length(parameternames)
eval([parameternames{ii} "=" num2str(parameters(ii)) ";"])
      endfor
     
      v1 = extvar(1);
      v2 = extvar(2);
      x  = intvar(1);
      if (x <= 0)
        H = RH;
        Hp = 0;
      elseif (x > 0 && x < 1)
        H = RH - (RH - RL) * x;
        Hp = - (RH - RL);
      else
        H = RL;
        Hp = 0;
      endif
      I  = (v1-v2) / H;
      i1 = I;
      i2 = -I;
      dIdx = - Hp / H^2;
      dIdV = 1 / H;
      a = zeros (3);
      a(3, 3) = 1/ MU;
     
      b = [dIdV  -dIdV dIdx;
          -dIdV dIdV  -dIdx;
          -dIdV dIdV  -dIdx];
     
      c = [i1 i2 i2]';
     
      break;
     
    otherwise
      error (["unknown section:" string])
  endswitch
endfunction
</syntaxhighlight>
}}
349

edits