%  Name of program: buildXYForPlot
%
%  Developed by: Enrico Bertolazzi
%                Department of Mechanical and Structural Engineering
%                enrico.bertolazzi@ing.unitn.it
%                http://www.ing.unitn.it/~bertolaz/
%
%  Last revision: 2 June 2009
%
%  Given a vector CB of cells boundary edges and a vector Q of cell average values
%  build the vectos x and y which can be used to plot the piecewise constant function
%  which represents the solution
%
%  INPUT
%    Xnodes: cells boundary       (row vector)
%    Q:      cell average value
%
%  OUTPUT
%    X:  x-coordinate 
%    Y:
%
%          +------+------+
%          |      |       |      +------+
%   +------+      |       |      |      |
%   |      |      |       +------+      |
%   | Q(1) | Q(2) | Q(3)  | Q(4) |      |
%   |      |      |       |      |      |
% CB(1)  CB(2)  CB(3)
%
%  Last revision: 2 June 2009
%
function [X,Y] = buildXYForPlot( Xnodes, Q )

  % allocate memory
  N = size(Q,2) ;
  X = zeros( 1,         2*N ) ;
  Y = zeros( size(Q,1), 2*N ) ;

  X(1:2:2*N-1) = Xnodes(1:end-1) ;
  X(2:2:2*N)   = Xnodes(2:end) ;

  Y(:,1:2:2*N-1) = Q ;
  Y(:,2:2:2*N)   = Q ;
                                    
end

