function [dx] = generatePlaidDX(minDX,maxDX,plaidRate,smallRegion,xdist) % function [bathStruct] = generatePlaidDX(minDX,maxDX,plaidRate,smallRegion,xdist) % % Generate an array of plaid dx for use with modifyELCOMbathyGridSize % % Inputs: % minDX : minimum value of dx for the gris % maxDX : maximum value of dx for the grid % plaidRate : the rate to increase from min DX to max DX % smallRegion : a 1x2 array for region to contain small dx values e: [0 4000] % xdist : the total distance required. % % Outputs % dx : the array of dx values % % Uses: % % Written by C. Dallimore 20 July 06 % % get an array of dx for the varying width region i=1; plaidDX(i) = plaidRate*minDX; while plaidDX < maxDX plaidDX(i+1) = plaidRate*plaidDX(i); i = i+1; end plaidDX = plaidDX(1:i-1); plaidDist = sum(plaidDX); % initailise dx=[]; % Do we need maxDX cells before the small dx region if smallRegion(1)-plaidDist <0 % Do we need varying cells before the small dx region n = 0; plaidDistTmp = 0; while smallRegion(1) - plaidDistTmp > 0 n = n+1; plaidDistTmp=plaidDistTmp+plaidDX(n); end for i =1:length(plaidDX) dx(i)=plaidDX(length(plaidDX)-i+1); end % Fill in the small dx region thisX = n; while sum(dx) < smallRegion(2) thisX = thisX+1; dx(thisX) = minDX; end % Move out from small dx region with varying width cells until we get to maxDX % then fill to we get to xdist n = 1; while sum(dx) < xdist thisX = thisX +1; if n > length(plaidDX) dx(thisX)=maxDX; else dx(thisX)=plaidDX(n); end n = n+1; end else % Fill with maxDX until we get close enough to small region to use varying cells thisX =1; while sum(dx)+plaidDist length(plaidDX) dx(thisX)=maxDX; else dx(thisX)=plaidDX(n); end n = n+1; end end