Code covered by the BSD License  

Highlights from
Streamcolor

Be the first to rate this file! 24 Downloads (last 30 days) File Size: 2.39 KB File ID: #24049
image thumbnail

Streamcolor

by

 

Draw 2D or 3D color streamlines.

| Watch this File

File Information
Description

STREAMCOLOR(X,Y,U,V,STARTX,STARTY,VMAG) or STREAMCOLOR(X,Y,Z,U,V,W,STARTX,STARTY,STARTZ,VMAG) creates streamlines from 2D or 3D vector data U,V,W. The arrays X,Y,Z define the coordinates for U,V,W and must be monotonic and 3D plaid (as if produced by MESHGRID). STARTX, STARTY, and STARTZ define the starting positions of the stream lines. The handles is NOT returned due to color coding information. Vmag is a matrix of values defines at X,Y,Z. It can be the velocity magnitude or any other variable (vorticity, tke, salinity etc...)

MATLAB release MATLAB 6.5 (R13)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
26 Jun 2013 Mathieu

Great function!
I found one bug, since a colorbar of sizze 64 is assumed, Vcol should be defined as:

Vcol=uint8(floor(interp2(x,y,vmag,X,Y)/vmax*size(cmap,1)));

I also managed to speed up the function by looping through the colormap instead of X. This makes the function 100 times faster. In 2d, this gives:

for k = 1:length(verts);
vv = verts{k};
if ~isempty(vv)
X=vv(:,1); Y=vv(:,2);
Vcol=uint8(floor(interp2(x,y,vmag,X,Y)/vmax*size(cmap,1)));
Vcol(Vcol==0)=1;
for j=1:size(cmap,1),
pos = find(Vcol==j);
if(~isempty(pos) & pos(1)==1), pos(1)=[]; end
if ~isempty(pos),
tempx = [X(pos-1) X(pos) NaN(size(pos))]';
tempy = [Y(pos-1) Y(pos) NaN(size(pos))]';
line(tempx(1:end-1),tempy(1:end-1),'color',cmap(j,:),'linewidth',lw);
end
end
end
end

Contact us