title: Bar3 plot with seperate x,y,height and width values
body: <blockquote>
    <p><strong><em>Solution posted below</em></strong> function to plot bar 3 with separate x, y values and separate width and height values </p>
    
    <p><strong>bar3(x,y,z,xWidth,yWidth)</strong></p>
  </blockquote>
  
  <p>We are currently working on a project that allow one to visualize the area under a 3d function, f(x,y). The purpose of this is to demonstrate how the bars cut a 3d surface. Indirectly to visualize the desired integral.</p>
  
  <p><strong>We wish to have the bars match up with the intervals of the surface grid.</strong>
  Below is a rough demonstration of the idea.</p>
  
  <p><a href="https://i.stack.imgur.com/CScfa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CScfa.jpg" alt="example of idea"></a></p>
  
  <p>bar3 only has input for the x-values <strong>bar3(x,z)</strong>, where as surf has a input for both the x and y <strong>surf(x,y,z)</strong></p>
  
  <p>Unfortunately this is what we are getting. <strong>- this is because bar3 cant be in terms of x and y</strong></p>
  
  <p><a href="https://i.stack.imgur.com/q1tdu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q1tdu.jpg" alt="gui"></a></p>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>clc;
  cla;
  d=eval(get(handles.edtOuterUpperB,'string'));
  c=eval(get(handles.edtOuterLowerB,'string'));
  b=eval(get(handles.edtInnerUpperB,'string'));
  a=eval(get(handles.edtInnerLowerB,'string'));
  
  n=eval(get(handles.edtInnerInterval,'string'));
  m=eval(get(handles.edtOuterInterval,'string'));
  
  h=(b-a)/n;
  k=(d-c)/m;
  
  [x,y] = meshgrid(a:h:b, c:k:d);
  f=eval(get(handles.edtFunc,'string'));
  surf(x,y,f);
  
  hold on
  bar3(f,1);
  </code></pre>