0001 function hh = quiverc(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 alpha = 0.33;
0050 beta = 0.23;
0051 autoscale = 1;
0052 plotarrows = 1;
0053 sym = '';
0054
0055 nin = nargin;
0056
0057
0058 if nin<4,
0059 [msg,x,y,u,v] = xyzchk(varargin{1:2});
0060 else
0061 [msg,x,y,u,v] = xyzchk(varargin{1:4});
0062 end
0063 if ~isempty(msg), error(msg); end
0064
0065 if nin==3 | nin==5,
0066 autoscale = varargin{nin};
0067 minrng = [];
0068 maxrng = [];
0069 usecolormap = [];
0070 cptfullfile = [];
0071 elseif nin==9,
0072 autoscale = varargin{5};
0073 minrng = varargin{6};
0074 maxrng = varargin{7};
0075 usecolormap = varargin{8};
0076 cptfullfile = varargin{9};
0077 end
0078
0079
0080
0081
0082
0083 if ~isempty(cptfullfile) && strcmpi('Browse for more (cpt)...',usecolormap)
0084 CC = cptcmap(cptfullfile);
0085 elseif ~isempty(usecolormap)
0086 colormap(usecolormap)
0087 CC = colormap;
0088 else
0089 colormap('jet')
0090 CC = colormap;
0091 end
0092 c1 = CC(:,1); c2 = CC(:,2); c3 = CC(:,3);
0093 CCx = (1:size(CC,1))';
0094 clevs = linspace(1,size(CC,1),64)'; clevs(end) = size(CC,1);
0095 cc1 = interp1(CCx,c1,clevs);
0096 cc2 = interp1(CCx,c2,clevs);
0097 cc3 = interp1(CCx,c3,clevs);
0098 colormap([cc1 cc2 cc3]);
0099
0100 filled = 0;
0101 ls = '-';
0102 ms = '';
0103 col = '';
0104 lw=1;
0105
0106
0107 if prod(size(u))==1, u = u(ones(size(x))); end
0108 if prod(size(v))==1, v = v(ones(size(u))); end
0109
0110 if autoscale,
0111
0112
0113
0114
0115 if min(size(x))==1, n=sqrt(prod(size(x))); m=n; else [m,n]=size(x); end
0116 delx = diff([min(x(:)) max(x(:))])/n;
0117 dely = diff([min(y(:)) max(y(:))])/m;
0118 len = sqrt((u.^2 + v.^2)/(delx.^2 + dely.^2));
0119 autoscale = autoscale*0.9 / max(len(:));
0120 u = u*autoscale; v = v*autoscale;
0121 end
0122
0123
0124
0125 vr=sqrt(u.^2+v.^2);
0126 if ~isempty(minrng)
0127 a = 1; b = 64;
0128 vrn=round(...
0129 (b-a)*(vr-minrng*autoscale)...
0130 /(maxrng*autoscale-minrng*autoscale) + a...
0131 );
0132 vrn(vrn<1) = 1;
0133 vrn(vrn>64) = 64;
0134 else
0135 vrn=round(vr/max(vr(:))*64);
0136 end
0137 CC=colormap;
0138 ax = newplot;
0139 next = lower(get(ax,'NextPlot'));
0140 hold_state = ishold;
0141
0142
0143
0144
0145 x = x(:).';y = y(:).';
0146 u = u(:).';v = v(:).';
0147 vrn=vrn(:).';
0148 uu = [x;x+u;repmat(NaN,size(u))];
0149 vv = [y;y+v;repmat(NaN,size(u))];
0150 vrn1= [vrn;repmat(NaN,size(u));repmat(NaN,size(u))];
0151
0152 uui=uu(:); vvi=vv(:); vrn1=vrn1(:); imax=size(uui);
0153 hold on
0154
0155 for i= 1:3:imax-1
0156 ii=int8(round(vrn1(i)));
0157 if ii==0; ii=1; end
0158 c1= CC(ii,1); c2= CC(ii,2); c3= CC(ii,3);
0159 plot(uui(i:i+1),vvi(i:i+1),'linewidth',lw,'color',[c1 c2 c3]);
0160 end
0161
0162
0163
0164 if plotarrows,
0165
0166 hu = [x+u-alpha*(u+beta*(v+eps));x+u; ...
0167 x+u-alpha*(u-beta*(v+eps));repmat(NaN,size(u))];
0168 hv = [y+v-alpha*(v-beta*(u+eps));y+v; ...
0169 y+v-alpha*(v+beta*(u+eps));repmat(NaN,size(v))];
0170 vrn2= [vrn;vrn;vrn;vrn];
0171
0172 uui=hu(:); vvi=hv(:); vrn2=vrn2(:); imax=size(uui);
0173
0174 for i= 1:imax-1
0175 ii=int8(round(vrn2(i)));
0176 if ii==0; ii=1; end
0177 c1= CC(ii,1); c2= CC(ii,2); c3= CC(ii,3);
0178 plot(uui(i:i+1),vvi(i:i+1),'linewidth',lw,'color',[c1 c2 c3]);
0179 end
0180
0181 else
0182 h2 = [];
0183 end
0184
0185
0186 if ~isempty(ms),
0187 hu = x; hv = y;
0188 hold on
0189 h3 = plot(hu(:),hv(:),[col ms]);
0190 if filled, set(h3,'markerfacecolor',get(h1,'color')); end
0191 else
0192 h3 = [];
0193 end
0194
0195 if ~hold_state, hold off, view(2); set(ax,'NextPlot',next); end
0196
0197 if nargout>0, hh = [h1;h2;h3]; end
0198
0199
0200