1 |
function h=numbnd(fem_grid_struct,ps) |
---|
2 |
%NUMBND number boundary nodes on current axes in viewing region. |
---|
3 |
% |
---|
4 |
% INPUT : fem_grid_struct - (from LOADGRID, see FEM_GRID_STRUCT) |
---|
5 |
% ps - point size for screen text numbers |
---|
6 |
% (optional, def=15) |
---|
7 |
% |
---|
8 |
% OUTPUT : h - vector of handle to text objects drawn (optional) |
---|
9 |
% |
---|
10 |
% CALL : h=numbnd(fem_grid_struct,ps); |
---|
11 |
% |
---|
12 |
% Written by : Brian O. Blanton |
---|
13 |
% Summer 1997 |
---|
14 |
% |
---|
15 |
|
---|
16 |
% DEFINE ERROR STRINGS |
---|
17 |
err1=['Not enough input arguments; need atleast fem_grid_struct']; |
---|
18 |
err2=['Too many input arguments; type "help numbnd"']; |
---|
19 |
warn1=['The current axes is too dense for the ' |
---|
20 |
'node numbers to be readable. CONTINUE?']; |
---|
21 |
|
---|
22 |
% check arguments |
---|
23 |
if nargin ==0 |
---|
24 |
error(err1); |
---|
25 |
elseif nargin >2 |
---|
26 |
error(err2); |
---|
27 |
elseif nargin==1 |
---|
28 |
ps=15; |
---|
29 |
end |
---|
30 |
|
---|
31 |
if ~is_valid_struct(fem_grid_struct) |
---|
32 |
error(' Argument to NUMBND must be a valid fem_grid_struct.') |
---|
33 |
end |
---|
34 |
|
---|
35 |
% Extract grid fields from fem_grid_struct |
---|
36 |
% |
---|
37 |
bnd=fem_grid_struct.bnd; |
---|
38 |
x=fem_grid_struct.x; |
---|
39 |
y=fem_grid_struct.y; |
---|
40 |
|
---|
41 |
X=get(gca,'Xlim'); |
---|
42 |
Y=get(gca,'YLim'); |
---|
43 |
|
---|
44 |
% Since the boundary list is not guaranteed to be "ordered" |
---|
45 |
% we need to know the unique node numbers in the boundary |
---|
46 |
% |
---|
47 |
[nlist,ncount] = count(bnd(:)); |
---|
48 |
nlist=nlist(:); |
---|
49 |
|
---|
50 |
xb=x(nlist); |
---|
51 |
yb=y(nlist); |
---|
52 |
|
---|
53 |
% get indices of nodes within viewing window defined by X,Y |
---|
54 |
filt=find(xb>=X(1)&xb<=X(2)&yb>=Y(1)&yb<=Y(2)); |
---|
55 |
|
---|
56 |
% Build string matrix |
---|
57 |
temp=nlist(filt); |
---|
58 |
strlist=num2str(temp,6); |
---|
59 |
|
---|
60 |
xx=xb(filt);yy=yb(filt); |
---|
61 |
format long e |
---|
62 |
% label only those nodes that lie within viewing window. |
---|
63 |
htext=text(xx,yy,strlist,... |
---|
64 |
'FontSize',ps,... |
---|
65 |
'HorizontalAlignment','center',... |
---|
66 |
'VerticalAlignment','middle',... |
---|
67 |
'Color','k',... |
---|
68 |
'Tag','Bnd Node #'); |
---|
69 |
|
---|
70 |
if nargout==1,h=htext;,end |
---|
71 |
return |
---|
72 |
% |
---|
73 |
% Brian O. Blanton |
---|
74 |
% Department of Marine Sciences |
---|
75 |
% 15-1A Venable Hall |
---|
76 |
% CB# 3300 |
---|
77 |
% Uni. of North Carolina |
---|
78 |
% Chapel Hill, NC |
---|
79 |
% 27599-3300 |
---|
80 |
% |
---|
81 |
% 919-962-4466 |
---|
82 |
% blanton@marine.unc.edu |
---|
83 |
% |
---|
84 |
% Summer 1997 |
---|
85 |
% |
---|
86 |
|
---|
87 |
|
---|