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
Walter Roberson
2011년 12월 19일
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.
iceuday
2011년 12월 19일
Walter Roberson
2011년 12월 19일
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.
iceuday
2011년 12월 19일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!