Quiver plots using data from a loop

5 views (last 30 days)
600Seat
600Seat on 30 Apr 2013
I hope someone can help me with the following quiver mysterious.
I would like to plot velocity vectors as arrows with components (u,v) at the points (x,y). However, from the whole set of data, I would like to display only every certain x values (vertical lines) as in figure 1. I use a loop to obtain only the data that I would like to plot (i.e. every 140 values). Since I would like to use these specific data as matrix, I create X,Y,U,V. When I plot quiver of X,Y,U,V the plots are different. In particular,it seems one line starts differently than the next one (beginning of the grid columns)
I have tried using structures and I get the same. I check the matrix X,Y,U and V and they are the sames than by using the loop. Therefore I cannot understand why I dont get the same plot.
Could anyone explain me the reason?
Thanks
Thanks a lot in advance
------------------------------------ m1=1;
for k=1:140:length(x(1,:))
xp=x(:,k);
yp=y(:,k);
up=u(:,k);
vp=v(:,k);
X(:,m1)=xp;
Y(:,m1)=yp;
U(:,m1)=up;
V(:,m1)=vp;
figure(1)
h3=quiver(xp(1:15:end),yp(1:15:end),up(1:15:end),vp(1:15:end),1);
hold on
axis([0 600 0 70])
m1=m1+1;
end
figure(2)
h4=quiver(X(1:15:end),Y(1:15:end), U(1:15:end),V(1:15:end),1);
axis([0 600 0 70])
Figure 1:
Figure 2:
  2 Comments
Sean de Wolski
Sean de Wolski on 30 Apr 2013
I'm not clear on what you want and don't want.
600Seat
600Seat on 1 May 2013
u,v data means velocity field of a flow. The x values mean distance in horizontal, and the y values mean heights. I would like to plot the field velocity only every certain distance in x. Lest say I would like to get all u,v for x= 0, 55, 110, etc. As it is plot in figure 1. In order to get the figure 1, I created a loop where I only read data every certain increment and the plot is created line by line according to the for end command, as following:
for k=1:140:length(x(1,:))
xp=x(:,k);
yp=y(:,k);
up=u(:,k);
vp=v(:,k);
igure(1)
h3=quiver(xp(1:15:end),yp(1:15:end),up(1:15:end),vp(1:15:end),1);
hold on
end
However, I dont want the plot to be created line by line as part of the loop. I would like to keep the 'important' data in a matrix with x,y,u,v values and to plot it outside the loop. For this, I created a counter m=1, m=m+1 and matrix to keep the values, i.e. X(:,m1)=xp; Y(:,m1)=yp; U(:,m1)=up; V(:,m1)=vp;
However, when I plot the values of X,Y,U and V after the loop ends (figure 2) the velocity values are not exactly the same. In particular, if you look at the grid (because there is a lot of zeros for u and v), figure 1 is squared but figure 2 is more like diagonal...
Why figure 1 is different than figure 2?
I hope it is a little more clear now.
thanks a lot in advance

Sign in to comment.

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!