Plotting streamlines in matlab.

조회 수: 10 (최근 30일)
Naveen K S
Naveen K S 2019년 4월 24일
댓글: darova 2019년 4월 24일
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.

채택된 답변

darova
darova 2019년 4월 24일
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
Naveen K S
Naveen K S 2019년 4월 24일
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 2019년 4월 24일
Delete first row of your data (it's defective)
and change axis boundaries
axis ([ xmin xmax ymin ymax])

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by