Plotting streamlines in matlab.

11 vues (au cours des 30 derniers jours)
Naveen K S
Naveen K S le 24 Avr 2019
Commenté : darova le 24 Avr 2019
I am trying plot streamlines using the streamlinefunction. The number of streamlines i'm getting streamlines are way too less. I am attaching the code and the data file containing the velocity components and their co-ordinates. please help me in resolving the issue.

Réponse acceptée

darova
darova le 24 Avr 2019
Just increased number of starting points
img1.png img2.png
n = 100; % number of streamlines
starting_x = zeros(1,n); % starting points for streamlines
starting_y = linspace(-0.1,0.1,n);
  3 commentaires
Naveen K S
Naveen K S le 24 Avr 2019
After your suggestion i have edited the code as below. But I'm getting streamlines like in the attached file
mag_V = sqrt( velcomppos.Vx.^2 + velcomppos.Vy.^2);
% Filtering out zero velocity walls.
index = mag_V > 0.01;
xx = velcomppos.x(index);
yy = velcomppos.y(index);
Vxx = velcomppos.Vx(index);
Vyy = velcomppos.Vy(index);
FVx = scatteredInterpolant(xx,yy,Vxx,'linear','none');
FVy = scatteredInterpolant(xx,yy,Vyy,'linear','none');
%FVz = scatteredInterpolant(xx,yy,zz,Vzz,'linear','none');
% This is a very ugly grid for your problem but it works.
% A cylindrical grid would probably be more resource efficient
elements = 78; % how many subdivisions per dimensions.
% Mind you, this is 3D. Total memory gets large fast
[X3, Y3] = meshgrid(linspace(min(velcomppos.x),max(velcomppos.x),elements),...
linspace(min(velcomppos.y),max(velcomppos.y),elements));
%linspace(min(velcomppos.z),max(velcomppos.z),elements));
V3x = FVx(X3,Y3);
V3y = FVy(X3,Y3);
%V3z = FVz(X3,Y3);
mag_V3 = sqrt(V3x.^2 + V3y.^2); % velocity vector magnitude
n=100;
starting_x = zeros(1,n); % starting points for streamlines
starting_y = linspace(-0.1,0.1,n);
%[starting_y] = meshgrid(linspace(-0.007,.007,7));
(linspace(-0.1,.1,n));
figure(1)
clf
%plot(velcomppos.x,velcomppos.y,'.k','MarkerSize',1);
hold on
%quiver(velcomppos.x,velcomppos.y,velcomppos.Vx,velcomppos.Vy);
%h = slice(X3,Y3,mag_V3,[],0,-0.02:.02:0);
%set(h,'EdgeColor','w','FaceAlpha',0.75');
streamline(X3,Y3,V3x,V3y,starting_x,starting_y);
%set(h,'color','r','LineWidth',4);
axis ([ 0.170 0.35 -0.1 0.07])
grid on
hold on
xlabel('x');
ylabel('y');
set(get(gca,'YLabel'),'Rotation',0);
darova
darova le 24 Avr 2019
Delete first row of your data (it's defective)
and change axis boundaries
axis ([ xmin xmax ymin ymax])

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Vector Fields dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by