Plot 2D streamline_issue
Ältere Kommentare anzeigen
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 Kommentar
Ameer Hamza
am 9 Mai 2020
variable Ug and Vg are also not defined in this code. Can you give the code with generates the figure in question?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Vector Fields finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

