Cross section plot for 2D plot

9 次查看(过去 30 天)
Tan Has
Tan Has 2012-10-3
I have a code to plot the quiver data.
I want to plot a 1D line plot across the 2D plot to see how the value of quiver changes from left to right alone a line.
Here is the code:
function[d]=DOMAINGENERATION_assocwithDNAPL(alpha, beta, kappa,Yo,CTD,vo)
fid = fopen('domain¶meter.dat'); % open file that will contain grid coordinate system and associated parameters
% for i = 1:5:45;
i=1;
% fh=figure;
m=4+(i-1)*11844;
n=11843+(i-1)*11844;
M=dlmread('3d2pct.plt',',',m,0, [m 0 n 9]); %3d2pct.plt data file
xarray=M(:,1);
yarray=M(:,2);
DV_XX=M(:,8);
DV_YY=M(:,9);
FRONT=M(:,3);
SF=reshape(FRONT,80,148);
X=reshape(xarray,80,148);
Y=reshape(yarray,80,148);
% figure;
v = [1 0.95:1.00];
contour(X(1,:),Y(:,1),SF,1);
colormap([0 0 0]);
hold on
quiver(xarray(1:4:end),yarray(1:4:end),DV_XX(1:4:end),DV_YY(1:4:end),1, 'k','filled');
hold on
xlabel('(m)');
ylabel('(m)');
set(gcf,'color',[1 1 1]);
set(gca,'color','none');
axis equal;
%*************** Plot area ***********************************************
axis([0 0.37 0 0.20])
%*************************************************************************
end

回答(1 个)

Babak
Babak 2012-10-3
Do you need to find the intersection of a 1D line and a curve that has been plotted in a 2D plane?
Did I understand your problem correctly?
The intersection will be a whole bunch of points if I understood you correctly.
  2 个评论
Tan Has
Tan Has 2012-10-3
编辑:Tan Has 2012-10-3
yes for question. you got it. Could you help me
Babak
Babak 2012-10-3
OK so here's my answer:
You need to have a boundry [xmin xmax] and [ymin ymax] that you are interested in finding the intersection of a line and your curve. Now, assume that the curve is given by its points as X=[x1 x2 x3...] and Y=[y1 y2 y3 ...] and the line you want to intersect it with is given by an equation y=a*x+b, the intersection includes points like (xj,yj) that satisfies yj=a*xj+b and if you find xj in X, it may be located somewhere between x(i) and x(i+1). The corresponding Y for x(i) and x(i+1) are y(i) and y(i+1). If y(i) and y(i+1) are close enough to yj and closer than y(i-1) and y(i+2) to yj then you can conclude that (xj,yj) is an intersection point.

请先登录,再进行评论。

类别

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