Cross section plot for 2D plot

9 views (last 30 days)
Tan Has
Tan Has on 3 Oct 2012
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

Answers (1)

Babak
Babak on 3 Oct 2012
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 Comments
Tan Has
Tan Has on 3 Oct 2012
Edited: Tan Has on 3 Oct 2012
yes for question. you got it. Could you help me
Babak
Babak on 3 Oct 2012
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.

Sign in to comment.

Categories

Find more on Vector Fields in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!