Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB Quiver - Tiny arrows

Tags:

matlab

I am trying to plot x and y velocities using quiver function in MATLAB.

I have x,y,u and v arrays(with their usual meanings) with dimension 100x100
So, the result is my quiver plot is dense and I cannot see the arrows unless I zoom in.
Somewhat like this: quiver not drawing arrows just lots of blue, matlab

Take a look at my plot: My quiver plot

Is there any way to make quiver plot less dense(and with bigger arrows)? I am planning to clip x-axis range to 0-4. But anything apart from that?

I cannot make my mesh less dense for accuracy concerns. I am, however willing to ignore some fine data points if that's required to make the plot look better.

like image 536
tumchaaditya Avatar asked Oct 30 '13 06:10

tumchaaditya


2 Answers

You can plot a reduced number of arrows by plotting, for example, (assuming your data are in arrays)

quiver(x(1:2:end,1:2:end),y(1:2:end,1:2:end),u(1:2:end,1:2:end),v(1:2:end,1:2:end))

where the 2 in this example means we plot only a quarter as many arrows. You can of course change it, as long as you change all of the 2's so that the arrays are all appropriately sized.

If you want to change the length of the arrows there are two options. Firstly, you can use the scale option scale=2 to scale the arrows by the amount specified, or you can normalise the velocities if you want to have all the arrows the same length. You do lose information doing that, because you can't compare the magnitude of the velocity by looking at the arrows, but it may be useful in some situations. You can do this by dividing u and v both by sqrt(u.^2+v.^2) (at the points you wish to plot arrows at.

Hope that helps and sets everything out nicely.

like image 118
David Avatar answered Sep 23 '22 01:09

David


You need to make your interval value a bit larger in order to make your matrix more sparse.

This is very dense:

1:0.0001:100

This is very sparse:

1:1:100

EDIT:

If you have the Image Processing Toolkit you can use the imresize function to reduce the matrix resolution:

newMat = imresize(oldMat, newSize); 

And if you don't have the Toolbox then you can resize in a similar manner to this example using interp2 Interpolation:

orgY = 1:size(oldMat,1); 
orgX = 1:size(oldMat,2); 
[orgX,orgY] = meshgrid(orgX ,orgY); 
newY = linspace(1,size(mat,1),newHeight); 
newX = linspace(1,size(mat,2),newWidth); 
[newX,newY] = meshgrid(newX,newY); 
newMat = interp2(orgX,orgY,mat,newX,newY);

And thanks to @David, if you want to just strip out some individual points you can simply do:

xPlot=x(1:2:end)
like image 22
Samuel O'Malley Avatar answered Sep 23 '22 01:09

Samuel O'Malley