NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/opnml/FCAST_1.2/boundline.m

Revision 495 (checked in by cbc, 11 years ago)

Initial import of Stark code.

Line 
1 function [xout,yout,hout,iout]=boundline(arg1,x,y,h)
2
3 % [XOUT,YOUT,HOUT,IOUT]=boundline(BND,X,Y,H)
4 % [XOUT,YOUT,HOUT,IOUT]=boundline(FNAME)
5 % [XOUT,YOUT,HOUT,IOUT]=boundline(MESH_STRUCTURE)
6 %
7 % Assembles a set of continuous boundary line locations, depths and
8 % node numbers for a mesh.
9
10 if nargin==0
11         arg1='marmap1';
12 end
13
14 if isstr(arg1)
15         [ele,x,y,h,bnd]=cgload(arg1);
16 elseif isstruct(arg1)
17         x=arg1.X;
18         y=arg1.Y;
19         h=arg1.H;
20         bnd=arg1.B;
21 else
22         bnd=arg1;
23 end
24
25 ho=[];
26 xo=[];
27 yo=[];
28 io=[];
29
30 while ~isempty(bnd)
31         ind=2;
32         indseries=nan*bnd(:,1)';
33         indseries(1:2)=bnd(1,:);
34         bnd=bnd(2:size(bnd,1),:);
35         while indseries(1)~=indseries(ind);
36                 nind=find(bnd(:,1)==indseries(ind));
37                 if isempty(nind)
38                         bnd=fliplr(bnd);
39                         nind=find(bnd(:,1)==indseries(ind));
40                 end
41                 ind=ind+1;
42                 indseries(ind)=bnd(nind,2);
43                 bnd=bnd([1:(nind-1) (nind+1):size(bnd,1)],:);
44         end
45         io=[io,indseries(1:ind),nan];
46         xo=[xo,x(indseries(1:ind))',nan];
47         yo=[yo,y(indseries(1:ind))',nan];
48         ho=[ho,h(indseries(1:ind))',nan];
49 end
50
51 if nargout
52         xout=xo;
53         yout=yo;
54         hout=ho;
55         iout=io;
56 else
57         plot(xo,yo)
58 end
Note: See TracBrowser for help on using the browser.