Gradient coloring of streamlines
25 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I'm currently using the streamline function https://fr.mathworks.com/help/matlab/ref/streamline.html to plot the streamlines of a flow I'm considering. I would like to have an "evoluting" color along the streamlines according to the flow speed in each point.
I don't know how to start ... Any hint will be very appreciated ! Here is my code that is ploting the streamlines :
%%%%%%%%%%%%%%%%%Shear over topo
alpha = 70 ;
lambda = 20 ;
k = cosd(alpha) * 2 *pi/lambda ;
l = sind(alpha) * 2 *pi/lambda ;
x = 0 : 0.1 : 50 ;
y = 0 : 0.1 :50 ;
A = 1;
B = 3 ;
Amp = 0.1/sqrt(k^2+l^2) ;
[X,Y] = meshgrid(x,y) ;
TauX = Amp * sqrt(A^2+B^2)*(k^2/sqrt(k^2+l^2)).*cos(k.*X+l.*Y + atan(B/A)) ;
TauY = Amp * sqrt(A^2+B^2)*(k*l/sqrt(k^2+l^2)).*cos(k.*X+l.*Y + atan(B/A)) ;
Topo = Amp .* cos(k.*X + l.*Y) ;
figure
imagesc(x,y,Topo)
hold on
hlines = streamline(X(1:step:end,1:step:end),Y(1:step:end,1:step:end),1 + TauX(1:step:end,1:step:end), TauY(1:step:end,1:step:end),0*y(1:step:end,1:step:end),y(1:step:end,1:step:end)) ;
set(hlines, 'Color', 'k')
Thank you very much !
0 comentarios
Respuestas (1)
Manish Annappa
el 12 de Jul. de 2017
As per your description, you either want to set different colors to each line in variable 'hlines' or you want to set multiple colors to a single line (varying colors along Y axis).
1) You can set different colors to each line using the code snippet below.
colorstring = 'kbgry';
for i = 1:5
set(hlines(i), 'Color', colorstring(i))
end
2) As per the link below, it is not possible to set different colors for different region of a line.
However, below link that illustrates the usage of patch objects may help you.
0 comentarios
Ver también
Categorías
Más información sobre Vector Fields en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!