Plot 2D streamline_issue
이전 댓글 표시
I need a help to plot 2D streamline along with the contour plot. I am unable to plot the steamline properly(startx,stary). I am attaching my plot in the figure. It is starting from the middle for some reason. kindly help me to solve it. I am attaching the data files for your refernce to test it.
navg = 11;
filenames = cell(navg,1);
for i = 1:navg
filenames = sprintf('queen2_test_%d.txt', i);
mydata{i}=importdata(filenames);
% writematrix(avg_mat{i}, filenames{i});
R = mydata{i}(:,1);%X
C = mydata{i}(:,2);%Y
U = mydata{i}(:,3);
V = mydata{i}(:,4);
F = mydata{i}(:,7)./5;%F(X,Y)
F(isnan(F)) = 0;
% F = max(F,0);
rg = linspace(0, max(R), 100);
cg = linspace(0, max(C), 100);
[Rg, Cg] = meshgrid(rg, cg);
Fg = griddata(R, C, F, Rg, Cg);
Ug = griddata(R, C, U, Rg, Cg);
Vg = griddata(R, C, V, Rg, Cg);
figure
ax = axes();
caxis([-5 5])
colorbar
ax.YDir = 'reverse';
% ax.Position(2) = ax.Position(2)+0.02;
hold on;
[CC,HH] = (contourf(Rg,Cg,Fg));
set(HH,'LineColor','none')
% contourf(peaks(20),10,'edgecolor','none');
colormap(bluewhitered);
ax.XAxisLocation = 'top';
% cb = colorbar('Location', 'south');
% cb.Position(2) = cb.Position(2)-0.11;
grid on;
hold on
xstart = linspace(.025, max(R),300);
ystart = .005*ones(size(xstart));
s = streamline(Rg,Cg,Ug,Vg,Rg,Cg,[0.1,10000]);
% s = streamline(Rg,Cg,Ug,Vg,xstart,ystart,[0.1,10000]);
% [s.Color] = deal('g');
quiver(R,C,U,V);
end

댓글 수: 1
Ameer Hamza
2020년 5월 9일
variable Ug and Vg are also not defined in this code. Can you give the code with generates the figure in question?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Vector Fields에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

