reading values from a graph
이전 댓글 표시
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
Jan
2011년 12월 11일
What is the purpose of "for ly = 0.5"? Have you read the "help for" text already?
iceuday
2011년 12월 11일
Fangjun Jiang
2011년 12월 11일
Where is figure 2? What is V? I am not clear what you want do.
iceuday
2011년 12월 12일
Walter Roberson
2011년 12월 12일
File exchange is not the right place for such things.
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
iceuday
2011년 12월 12일
Walter Roberson
2011년 12월 12일
Your figure does not correspond to your plot command. When you use plot(V) then the x coordinates which would be implied would be x = 1 : length(V) but your figure is clearly labeled for x = 0 to 1.
Please show the actual plotting command that you use. Different plot mechanism have different ways that would be best for extracting the information you are interested in.
iceuday
2011년 12월 12일
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개)
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!