title: Dimensionality issue with Matlab Function
body: <p>I thought this should be fairly simple, I really have no idea what went wrong, been trying for a week, gosh!! so ashamed of myself.</p>
  
  <p>I define the following at Workspace:</p>
  
  <pre><code>I = [5 5.1 5.2 5.2];
  V = [95 80 85 20];
  </code></pre>
  
  <p>I expect an output like this:</p>
  
  <pre><code>%// at t=0
  arr=20
  
  %// at t=1    
  arr=30
  
  %// at t=2
  arr=40
  </code></pre>
  
  <p>When I run the simulation, what I got is:</p>
  
  <pre><code>%// at t=0
  arr = 20, 0, 0, 0
  
  %// at t=1
  arr = 0, 10, 0, 0
  
  %// at t=2
  arr = 0, 0, 10, 0
  </code></pre>
  
  <p>There are few problems with this result:</p>
  
  <ol>
  <li><p>I expect only one <code>arr</code> value at a particular time, but it came out four <code>arr</code> values at a time</p></li>
  <li><p>I wonder why the <code>arr</code> never adds up to 30 and 40 etc</p></li>
  </ol>
  
  <p>My system is as follow:</p>
  
  <p><img src="https://i.stack.imgur.com/bv3gj.jpg" alt="enter image description here"></p>
  
  <p>The codes are here:</p>
  
  <p><img src="https://i.stack.imgur.com/gQJIu.jpg" alt="enter image description here"></p>
  
  <p>I managed to get only one value at a time, but why the arr never adds up to 30 and 40 etc? it keeps detecting that arr(count-1,1) is ALWAYS zero </p>