1 |
function h=plotdrog3(x,y,z,ndrog,tstride,dstride) |
---|
2 |
%PLOTDROG3 plot drogue .pth file output from DROG3D or DROG3DDT. |
---|
3 |
% PLOTDROG3 plots the paths of drogue locations as specified |
---|
4 |
% in the x,y,z coordinates. PLOTDROG3 takes as required |
---|
5 |
% arguments the x,y,z coordinates of the drogue locations AND |
---|
6 |
% the number of drogues in the path file. The path information |
---|
7 |
% from DROG3D or DROG3DDT can be read into MATLAB with |
---|
8 |
% READ_PTH, which reads .pth files. |
---|
9 |
% |
---|
10 |
% PLOTDROG3 draws each drogue with a separate line, solid |
---|
11 |
% by default. Each drogue line is referenced with |
---|
12 |
% one object handle. Therefore, to change the linetype or |
---|
13 |
% color of the lines, use the MATLAB command SET and the handle |
---|
14 |
% returned by PLOTDROG3. |
---|
15 |
% |
---|
16 |
% INPUT: |
---|
17 |
% x,y,z - x,y coordinates of drogues |
---|
18 |
% ndrog - number of drogues in path matrix; |
---|
19 |
% this number is returned by READ_PTH |
---|
20 |
% tstride - time stride (optional, def = 1) is |
---|
21 |
% the number of timesteps to skip over. 1 would |
---|
22 |
% mean "plot all timesteps"; 2 would mean "plot |
---|
23 |
% every other timestep"; i.e., skip every other |
---|
24 |
% timestep; etc... |
---|
25 |
% dstride - drogue stride (optional, def = 1) is |
---|
26 |
% the number of drogues to skip; see tstride above. |
---|
27 |
% In order to specify dstride, you must also specify |
---|
28 |
% tstride. |
---|
29 |
% |
---|
30 |
% Both tstride and dstride can be vectors of specific timesteps |
---|
31 |
% or drogue numbers to plot. In order to plot only ONE drogue |
---|
32 |
% or ONE timestep, pass into PLOTDROG3 the values of tstride |
---|
33 |
% and/or dstride enclosed in {}'s. For example, to |
---|
34 |
% plot the initial drogue locations, call PLOTDROG3 as: |
---|
35 |
% >> h=plotdrog3(x,y,ndrog,{1}); |
---|
36 |
% To plot the 3rd drogue for all timesteps, call PLOTDROG3 as: |
---|
37 |
% >> h=plotdrog3(x,y,ndrog,1,{3}); |
---|
38 |
% |
---|
39 |
% OUTPUT: |
---|
40 |
% h - the handle(s) to the path lines on the current axes |
---|
41 |
% |
---|
42 |
% dstride - the number of drogues to skip, see tstride above. |
---|
43 |
% In order to specify dstride, you must also specify |
---|
44 |
% tstride. |
---|
45 |
% |
---|
46 |
% CALL: h=plotdrog3(x,y,ndrog); |
---|
47 |
% h=plotdrog3(x,y,ndrog,tstride); |
---|
48 |
% h=plotdrog3(x,y,ndrog,tstride,dstride); |
---|
49 |
|
---|
50 |
% Written by: Brian O. Blanton |
---|
51 |
% |
---|
52 |
|
---|
53 |
% DEFINE ERROR STRINGS |
---|
54 |
err1=['PLOTDROG3 requires 4, 5, or 6 arguments.']; |
---|
55 |
err2=['tstride argument to PLOTDROG3 must be a positive integer(s).']; |
---|
56 |
err3=['dstride argument to PLOTDROG3 must be a positive integer(s).']; |
---|
57 |
err4=['Lengths of x,y,z to PLOTDROG3 must be equal.']; |
---|
58 |
err5=['Path length inconsistent with number of drogues specified in PLOTDROG3']; |
---|
59 |
err6=['ndrog argument to PLOTDROG3 must be a positive integer.']; |
---|
60 |
err7=['tstride argument to PLOTDROG3 must be less than number of timesteps.']; |
---|
61 |
err8=['dstride argument to PLOTDROG3 must be less than number of drogs.']; |
---|
62 |
err9=['Cell argument tstride to PLOTDROG3 must be of length 1']; |
---|
63 |
err10=['Cell argument dstride to PLOTDROG3 must be of length 1']; |
---|
64 |
|
---|
65 |
% check arguments |
---|
66 |
if nargin < 4 | nargin > 6, error(err1),end |
---|
67 |
|
---|
68 |
% If we're here, the first 4 required arguments exist. |
---|
69 |
if ndrog<0 | ~isint(ndrog), error(err6),end |
---|
70 |
|
---|
71 |
% Check x,y,z lengths |
---|
72 |
if length(x)~=length(y),error(err4),end |
---|
73 |
if length(x)~=length(z),error(err4),end |
---|
74 |
|
---|
75 |
% Make sure length(x)/ndrog is an integer. |
---|
76 |
if ~isint(length(x)/ndrog),error(err5),end |
---|
77 |
|
---|
78 |
% number of timesteps in length(x) |
---|
79 |
nts=length(x)/ndrog; |
---|
80 |
|
---|
81 |
% Check remaining (optional) arguments |
---|
82 |
if nargin>4 |
---|
83 |
% Atleast tstride has been specified. |
---|
84 |
% Is it a cell array? |
---|
85 |
if isa(tstride,'cell') |
---|
86 |
for i=1:length(tstride) |
---|
87 |
temp(i)=tstride{i}; |
---|
88 |
end |
---|
89 |
tstride=temp; |
---|
90 |
else |
---|
91 |
if length(tstride)==1 |
---|
92 |
if tstride<1 | ~isint(tstride), error(err2),end |
---|
93 |
tstride=1:tstride:nts; |
---|
94 |
else |
---|
95 |
tstride=sort(tstride(:)); |
---|
96 |
if min(tstride)<1 | ~isint(tstride), error(err2),end |
---|
97 |
end |
---|
98 |
end |
---|
99 |
|
---|
100 |
if nargin==6 |
---|
101 |
% Is dstride a cell array? |
---|
102 |
if isa(dstride,'cell') |
---|
103 |
temp=dstride{1}; |
---|
104 |
for i=1:length(dstride) |
---|
105 |
temp(i)=dstride{i}; |
---|
106 |
end |
---|
107 |
dstride=temp; |
---|
108 |
else |
---|
109 |
if length(dstride)==1 |
---|
110 |
if dstride<1 | ~isint(dstride), error(err3),end |
---|
111 |
dstride=1:dstride:ndrog; |
---|
112 |
else |
---|
113 |
dstride=sort(dstride(:)); |
---|
114 |
if min(dstride)<1 | ~isint(dstride), error(err3),end |
---|
115 |
end |
---|
116 |
end |
---|
117 |
else |
---|
118 |
dstride=1:ndrog; |
---|
119 |
end |
---|
120 |
else |
---|
121 |
tstride=1:nts; |
---|
122 |
dstride=1:ndrog; |
---|
123 |
end |
---|
124 |
|
---|
125 |
% Check tstride,dstride against nts,ndrog |
---|
126 |
if max(tstride)>nts,error(err7),end |
---|
127 |
if max(dstride)>ndrog,error(err8),end |
---|
128 |
|
---|
129 |
% reshape x,y,z into matrices of dimension ndrog x ntimestep |
---|
130 |
X=reshape(x,ndrog,nts)'; |
---|
131 |
Y=reshape(y,ndrog,nts)'; |
---|
132 |
Z=reshape(z,ndrog,nts)'; |
---|
133 |
|
---|
134 |
% reduce by tstride |
---|
135 |
X=X(tstride,:); |
---|
136 |
Y=Y(tstride,:); |
---|
137 |
Z=Z(tstride,:); |
---|
138 |
|
---|
139 |
% reduce by dstride |
---|
140 |
X=X(:,dstride); |
---|
141 |
Y=Y(:,dstride); |
---|
142 |
Z=Z(:,dstride); |
---|
143 |
|
---|
144 |
% Add NaN row to bottom of X,Y |
---|
145 |
[m,n]=size(X); |
---|
146 |
NN=NaN*ones(size(1:n)); |
---|
147 |
X=[X;NN]; |
---|
148 |
Y=[Y;NN]; |
---|
149 |
Z=[Z;NN]; |
---|
150 |
|
---|
151 |
if length(tstride)==1 |
---|
152 |
hout=line(X,Y,Z,'Tag','Drogue Path',... |
---|
153 |
'LineStyle','none',... |
---|
154 |
'Marker','.','Color','r'); |
---|
155 |
else |
---|
156 |
hout=line(X,Y,Z,'Tag','Drogue Path'); |
---|
157 |
end |
---|
158 |
|
---|
159 |
% Fill output argument if returned. |
---|
160 |
if nargout==1,h=hout;,end |
---|
161 |
|
---|
162 |
% |
---|
163 |
% Brian O. Blanton |
---|
164 |
% Department of Marine Science |
---|
165 |
% 15-1A Venable Hall |
---|
166 |
% CB# 3300 |
---|
167 |
% Uni. of North Carolina |
---|
168 |
% Chapel Hill, NC |
---|
169 |
% 27599-3300 |
---|
170 |
% |
---|
171 |
% 919-962-4466 |
---|
172 |
% blanton@marine.unc.edu |
---|
173 |
% |
---|
174 |
% Summer 1998 |
---|
175 |
% |
---|
176 |
|
---|