changed Tobias Höffken 3-14-05 totally downstripped version of the former split input field into n segments and do a quiver qhich each of them
0001 function hh = quiverc2(varargin) 0002 0003 % changed Tobias Höffken 3-14-05 0004 % totally downstripped version of the former 0005 % split input field into n segments and do a quiver qhich each of them 0006 0007 % Modified version of Quiver to plots velocity vectors as arrows 0008 % with components (u,v) at the points (x,y) using the current colormap 0009 0010 % Bertrand Dano 3-3-03 0011 % Copyright 1984-2002 The MathWorks, Inc. 0012 0013 % changed T. Höffken 14.03.05, for high data resolution 0014 % using fixed color "spacing" of 20 0015 0016 %QUIVERC Quiver color plot. 0017 % QUIVERC(X,Y,U,V) plots velocity vectors as arrows with components (u,v) 0018 % at the points (x,y). The matrices X,Y,U,V must all be the same size 0019 % and contain corresponding position and velocity components (X and Y 0020 % can also be vectors to specify a uniform grid). QUIVER automatically 0021 % scales the arrows to fit within the grid. 0022 % 0023 % QUIVERC(U,V) plots velocity vectors at equally spaced points in 0024 % the x-y plane. 0025 % 0026 % QUIVERC(U,V,S) or QUIVER(X,Y,U,V,S) automatically scales the 0027 % arrows to fit within the grid and then stretches them by S. Use 0028 % S=0 to plot the arrows without the automatic scaling. 0029 % 0030 % QUIVERC(...,LINESPEC) uses the plot linestyle specified for 0031 % the velocity vectors. Any marker in LINESPEC is drawn at the base 0032 % instead of an arrow on the tip. Use a marker of '.' to specify 0033 % no marker at all. See PLOT for other possibilities. 0034 % 0035 % QUIVERC(...,'filled') fills any markers specified. 0036 % 0037 % H = QUIVERC(...) returns a vector of line handles. 0038 % 0039 % Example: 0040 % [x,y] = meshgrid(-2:.2:2,-1:.15:1); 0041 % z = x .* exp(-x.^2 - y.^2); [px,py] = gradient(z,.2,.15); 0042 % contour(x,y,z), hold on 0043 % quiverc(x,y,px,py), hold off, axis image 0044 % 0045 % See also FEATHER, QUIVER3, PLOT. 0046 % Clay M. Thompson 3-3-94 0047 % Copyright 1984-2002 The MathWorks, Inc. 0048 % $Revision: 5.21 $ $Date: 2002/06/05 20:05:16 $ 0049 %------------------------------------------------------------- 0050 n=20; %# of colors 0051 0052 nin = nargin; 0053 0054 error(nargchk(2,5,nin)); 0055 0056 % Check numeric input arguments 0057 if nin<4, % quiver(u,v) or quiver(u,v,s) 0058 [msg,x,y,u,v] = xyzchk(varargin{1:2}); 0059 else 0060 [msg,x,y,u,v] = xyzchk(varargin{1:4}); 0061 end 0062 if ~isempty(msg), error(msg); end 0063 0064 %---------------------------------------------- 0065 % Define colormap 0066 vr = sqrt(u.^2+v.^2); 0067 CC = colormap; 0068 colit = ceil(((vr-min(vr(:)))./(max(vr(:))-min(vr(:))))*n); 0069 0070 0071 %---------------------------------------------- 0072 ucell = cell(20,1); 0073 vcell = cell(20,1); 0074 for it=(1:1:n) 0075 ucell{it}=ones(size(u))*NaN; 0076 vcell{it}=ones(size(u))*NaN; 0077 end 0078 0079 for jt=(1:1:length(u)) 0080 %it = ceil(((vr(jt)-min(vr(:)))/(max(vr(:))-min(vr(:))))*n); 0081 ucell{min(n,max(colit(jt),1))}(jt) = u(jt); 0082 vcell{min(n,max(colit(jt),1))}(jt) = v(jt); 0083 end 0084 0085 figure; 0086 hold on; 0087 for it=(1:1:n) 0088 c = CC(ceil(it/n*64),:); 0089 hh=quiver(x,y,ucell{it},vcell{it},varargin{5}*it/n,'Color',c); 0090 hold on; 0091 end 0092 0093 0094 0095 0096 0097