function [c,h] = scarpdater_contour3dmatrix(dim1vec,dim2vec,dim3vec,matrix,fixeddim,fixeddimindex,contourdata)

% Slices 3d matrix along dimension fixeddim (1,2,3) and produces contour plot
%    of other two independent dimensions.
% dim1vec, dim2vec, dim3vec are first, second, and third dimension values.
% matrix is 3d matrix to contour slice.
% fixeddim is the fixed dimension (other two dimensions will be contoured)
% fixeddimindex is the index at which the contour slice should be taken.
% contourdata is vector designating contour specifications.

switch fixeddim
   
  case 1
     contourmatrix = reshape(matrix(fixeddimindex,:,:),length(dim2vec),length(dim3vec));
     contourdim1 =  dim2vec;
     contourdim2 = dim3vec;
     
  case 2
     contourmatrix = reshape(matrix(:,fixeddimindex,:),length(dim1vec),length(dim3vec));
     contourdim1 = dim1vec;
     contourdim2 = dim3vec;
     
  case 3
     contourmatrix = reshape(matrix(:,:,fixeddimindex),length(dim1vec),length(dim2vec));
     contourdim1 = dim1vec;
     contourdim2 = dim2vec;
     
end

[c,h] = contour(contourdim1,contourdim2,contourmatrix',contourdata);
clabel(c,h);


  
