reading values from a graph

조회 수: 16 (최근 30일)
iceuday
iceuday 2011년 12월 11일
I have written a code which gives me a graphical output called figure 2.
Now i want to make my code take the all the values from figure 2, at y = 0.5 and plot the graph and write the values in a new file.
Figure 2 can be found at,
The code i wrote to do that is,
for ly = 0.5
figure(4), plot (V)
fid = fopen('V1.txt','w');
fprintf(fid,' V = %5.3f \n',V)
status = fclose(fid);
end
But there is a problem with this code which i have written as this code is plotting and fprintf all the values from figure 2.
So anyone how can guide/help/show me how to improve my code so that it reads values at y = 0.5 from Figure 2 and plot a graph using those values.
Thank you & Warm Regards, Day
----------------------------------------------------------
This is the code which i use to create my figure 1 and figure 2.
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
[Q,iter]=Stream(nx,ny,dx,dy,U,V);
figure(1), contourf(x(1:nx),y(1:ny),Q(1:nx,1:ny)',20,'k-');colormap;
axis equal, axis([0 lx 0 ly]); title(sprintf('Re = %0.1g t = %0.2g',Re,k*dt));
unode(1:nx,1:ny)=0.5*(U(1:nx,1:ny)+U(1:nx,2:ny+1));
vnode(1:nx,1:ny)=0.5*(V(1:nx,1:ny)+V(2:nx+1,1:ny));
figure(2), quiver(x,y,unode(1:nx,1:ny)',vnode(1:nx,1:ny)',2,'k-')
hold on, axis equal, axis([0 lx 0 ly])
title(sprintf('Re = %0.1g t = %0.2g',Re,k*dt))
drawnow
end
end
  댓글 수: 9
iceuday
iceuday 2011년 12월 12일
I have included my code which creates my figure 1 and figure 2.
So how do i create my figure 4 using values at y = 0.5 from figure 2.
Walter Roberson
Walter Roberson 2011년 12월 12일
Insufficiently defined. Do you want the graphic all along the line y=0.5 (e.g., the locations where each if the quiver arrows cross y=0.5), or do you want the unode() and vnode() pairs that would correspond to y = 0.5 ?
Is y = 0.5 exactly in the list of y (as it looks like it might be), or will it be necessary to interpolate the surrounding fields in order to determine the data for y = 0.5 ?
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 .
That is, one would see, a pair of numbers for each x, but your sample code has the look of expecting V to be a vector, a single number per x. You will need to clarify what you are expecting.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by