reading velocity vectors from figure 1 at ly = 0.5 and lx = 0.5 and plotting the graph

Hi everyone,
This code below creates figure 1,
if floor(25*k/nt)>floor(25*(k-1)/nt), fprintf('.'), end
if k==1|floor(nsteps*k/nt)>floor(nsteps*(k-1)/nt)
% stream function
rhs = reshape(diff(U')'/hy-diff(V)/hx,[],1);
q(perq) = Rq\(Rqt\rhs(perq));
Q = zeros(nx+1,ny+1);
Q(2:end-1,2:end-1) = reshape(q,nx-1,ny-1);
clf, contourf(avg(x),avg(y),P',20,'w-'), hold on
contour(x,y,Q',20,'k-');colormap;
Ue = [uS' avg([uW;U;uE]')' uN'];
Ve = [vW;avg([vS' V vN']);vE];
Len = sqrt(Ue.^2+Ve.^2+eps);
unode = (Ue./Len);
vnode = (Ve./Len);
quiver(x,y,unode',vnode',.4,'k-')
hold off, axis equal, axis([0 lx 0 ly])
p = sort(p); caxis(p([8 end-7]))
title(sprintf('Re = %0.1g t = %0.2g',Re,k*dt))
drawnow
end
end
Figure 1 can be found at,
http://imageshack.us/photo/my-images/830/figure1.jpg/ ____________________________________________________________
What i am trying to do now is to to plot a graph called figure 2 by taking the velocity values from figure 1 at, (lx=0.5) vertical center line (u-component) and the (ly=0.5) horizontal center line (v-component).
Figure 2 should look like, refer to the link below,
_____________________________________________________________
So can anyone guide me on how to achieve figure 2 ?
_____________________________________________________________
I tried creating figure 2 using the code below but it was incorrect.
for ly = 0.5
lyloc = find(abs(y - 0.5) < 100*eps(0.5), 1);
thisv = vnode(:, lyloc);
fid = fopen('ly=0.5.txt','w');
fprintf(fid,' %5.3f \n' ,thisv)
status = fclose(fid);
end
for lx = 0.5
lxloc = find(abs(x - 0.5) < 100*eps(0.5), 1);
thisu = unode(:, lxloc);
fid = fopen('lx=0.5.txt','w');
fprintf(fid,' %5.3f \n' ,thisu)
status = fclose(fid);
figure (2) , plot(thisu,thisv), axis([-1 1 -1 2])
end

댓글 수: 4

That is not my code. The code I gave indexes vnode and unode with the same index (and thus in the same loop). I would not give code that continually overwrote a variable needed after the loop, and I would not give code that keep overwriting the same file. Yes, I do see that the loops only go one iteration, but I would not have provided code that looked like that.
I am sorry Mr Walter.
You said,
"If y = 0.5 is exactly in the list of y, then
yloc = find(abs(y - 0.5) < 100*eps(0.5), 1);
thisu = unode(:, yloc);
thisv = vnode(:, yloc);
That is, thisu and thisv would give the vector field values all along the line y = 0.5 ."
I did as you said and tried other ways but i still cannot get my output to look like figure 2 in the link above.
I was not able to see the vector field arrows in your figure 1. I do see black lines, but those look to be lines from the contour() call.
The velocity vector field arrows are there, it is hard to see them as they are small and the blue color makes it difficult to view it.
I have uploaded another link for figure 1, refer to the link below,
http://imageshack.us/photo/my-images/406/figure1withvisibleveloc.jpg/

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

질문:

2011년 12월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by