# MATLAB: Can you make this source accept a variable declaration

function scatterbar3(X,Y,Z,width) % Original% function var = scatterbar3(X,Y,Z,width) What I'd like to be able to do.[r,c]=size(Z);for j=1:r,    for k=1:c,        if ~isnan(Z(j,k))            drawbar(X(j,k),Y(j,k),Z(j,k),width/2)        end    endendzlim=[min(Z(:)) max(Z(:))];if zlim(1)>0,zlim(1)=0;endif zlim(2)<0,zlim(2)=0;endaxis([min(X(:))-width max(X(:))+width min(Y(:))-width max(Y(:))+width zlim])caxis([0 50])function drawbar(x,y,z,width)h(1)=patch([-width -width width width]+x,[-width width width -width]+y,[0 0 0 0],'b');h(2)=patch(width.*[-1 -1 1 1]+x,width.*[-1 -1 -1 -1]+y,z.*[0 1 1 0],'b');h(3)=patch(width.*[-1 -1 -1 -1]+x,width.*[-1 -1 1 1]+y,z.*[0 1 1 0],'b');h(4)=patch([-width -width width width]+x,[-width width width -width]+y,[z z z z],'b');h(5)=patch(width.*[-1 -1 1 1]+x,width.*[1 1 1 1]+y,z.*[0 1 1 0],'b');h(6)=patch(width.*[1 1 1 1]+x,width.*[-1 -1 1 1]+y,z.*[0 1 1 0],'b');set(h,'facecolor','flat','FaceVertexCData',z)
• function all_h = scatterbar3(X,Y,Z,width) % Original    [r,c]=size(Z);    all_h = gobjects(r, c, 6);        for j=1:r,        for k=1:c,            if ~isnan(Z(j,k))                all_h(j, k, :) = drawbar(X(j,k),Y(j,k),Z(j,k),width/2)            end        end    end    zlim=[min(Z(:)) max(Z(:))];    if zlim(1)>0,zlim(1)=0;end    if zlim(2)<0,zlim(2)=0;end    axis([min(X(:))-width max(X(:))+width min(Y(:))-width max(Y(:))+width zlim])    caxis([0 50])function h = drawbar(x,y,z,width)    h(1)=patch([-width -width width width]+x,[-width width width -width]+y,[0 0 0 0],'b');    h(2)=patch(width.*[-1 -1 1 1]+x,width.*[-1 -1 -1 -1]+y,z.*[0 1 1 0],'b');    h(3)=patch(width.*[-1 -1 -1 -1]+x,width.*[-1 -1 1 1]+y,z.*[0 1 1 0],'b');    h(4)=patch([-width -width width width]+x,[-width width width -width]+y,[z z z z],'b');    h(5)=patch(width.*[-1 -1 1 1]+x,width.*[1 1 1 1]+y,z.*[0 1 1 0],'b');    h(6)=patch(width.*[1 1 1 1]+x,width.*[-1 -1 1 1]+y,z.*[0 1 1 0],'b');    set(h,'facecolor','flat','FaceVertexCData',z)