-
Notifications
You must be signed in to change notification settings - Fork 192
/
wavei.m
238 lines (131 loc) · 2.65 KB
/
wavei.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
%function[a,b]=wavei(z,x,y,mmin,mmax,sub1,sub2,cbar_label)
%
% function to make arbitrary image type color plots
%
% Kevin D. LePage
% SACLANTCEN
% 2/2/98
%
% INPUTS
%
% z vertical (color) information (matrix), must be real
% x optional x axis scale
% y optional y axis scale
% mmin minimum value of z to plot (optional)
% mmax maximum value of z to plot (optional)
% sub1 first subplot command (optional, default 1)
% sub2 second subplot command (optional, default 1)
% cbar_label
% colorbar label (defualt dB)
%
% OUTPUTS
%
% a handle to color figure
% b handle to colorbar
function[a,b]=wavei(z,x,y,mmin,mmax,sub1,sub2,cbar_label)
% check to see that the argument is real
pcolor_flag=0;
if isreal(z)~=1
fprintf('input argument is not real, breaking\n')
return
end
% replace infinite values with lowest non-infinite value
if sum(find(isinf(z)))~=0
fprintf('\rWarning: %d infinities were found, replacing with smallest real value',sum(find(isinf(z))))
if nargin<5
z(find(isinf(z)))=min(min(z(find(isinf(z)==0))))*ones(size(find(isinf(z))));
else
z(find(isinf(z)))=mmin*ones(size(find(isinf(z))));
end
end
%if sum(find(isnan(z)))~=0
%fprintf('\rWarning: %d NaN''s were found, replacing with smallest real value',sum(find(isnan(z))))
%if nargin<5
%z(find(isnan(z)))=min(min(z(find(isnan(z)==0))))*ones(size(find(isnan(z))));
%else
%z(find(isnan(z)))=mm*ones(size(find(isnan(z))));
%end
%end
% check to see if arguments are consistent with pcolor
if nargin<3
x=[1 size(z,2)];
y=[1 size(z,1)];
else
if ((length(x)==size(z,2)) & (length(y)==size(z,1)))
x=ones(size(z,1),1)*x(:)';
y=y(:)*ones(1,size(z,2));
end
if ((size(x)==size(z))&(size(y)==size(z)))
pcolor_flag=1;
end
end
if nargin>4
if isempty(find(z<mmin))
z(size(z,1),size(z,2))=mmin;
else
z(find(z<mmin))=mmin*ones(size(find(z<mmin)));
end
if isempty(find(z>mmax))
z(size(z,1)-1,size(z,2))=mmax;
else
z(find(z>mmax))=mmax*ones(size(find(z>mmax)));
end
end
if nargin>6
if((sub2==1)&(sub1>1))
clg
end
if sub1>6
subplot(ceil(sub1/3),3,sub2)
elseif sub1>3
subplot(ceil(sub1/2),2,sub2)
elseif sub1>1
subplot(sub1,1,sub2)
else
end
end
if pcolor_flag
a=pcolor(x,y,z);shading('flat');colormap('jet');
a=gca;
if exist('sub1')
if sub1>6
%b=colorbah('vert',6);
b=colorbar;
else
b=colorbar;
end
else
b=colorbar;
end
else
imagesc(x,y,z);colormap('jet');
axis('xy');
a=gca;
if exist('sub1')
if sub1>6
%b=colorbah('vert',6);
b=colorbar;
else
b=colorbar;
end
else
b=colorbar;
end
end
axes(b);
if exist('sub1')
if sub1>6
set(b,'FontSize',6)
end
end
if nargin==8
ylabel(cbar_label)
else
ylabel('dB')
end
axes(a)
if exist('sub1')
if sub1>6
set(a,'FontSize',6)
end
end