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 Commenti

Jan
Jan il 11 Dic 2011
What is the purpose of "for ly = 0.5"? Have you read the "help for" text already?
iceuday
iceuday il 11 Dic 2011
I wrote for ly=0.5 because I was thinking by doing this I can get the code to plot V for the values at ly=0.5 from figure 2.
But the code does not do that. So how do I get the code to read values from figure 2 at ly=0.5 and plot those set of values?
Fangjun Jiang
Fangjun Jiang il 11 Dic 2011
Where is figure 2? What is V? I am not clear what you want do.
iceuday
iceuday il 12 Dic 2011
figure 2 is a velocity field, i have uploaded the file but waiting for the file to be accepted and posted by file exchange.
V is the velocity in the y direction.
What i want to do is,
to obtain all the V velocity values from figure 2 at y=0.5 , so how am I going to write a code for that.
Walter Roberson
Walter Roberson il 12 Dic 2011
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
iceuday il 12 Dic 2011
Thank you Walter for the information.
Figure 2 can be found at this link below,
http://imageshack.us/photo/my-images/208/figure2i.jpg/
Figure 2 is a velocity field.
Walter Roberson
Walter Roberson il 12 Dic 2011
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
iceuday il 12 Dic 2011
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 il 12 Dic 2011
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.

Accedi per commentare.

Risposte (0)

Prodotti

Richiesto:

il 11 Dic 2011

Community Treasure Hunt

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

Start Hunting!

Translated by